Skip to content

Commit

Permalink
Merge pull request #231 from rhyw/add-failed-tasks-in-menu
Browse files Browse the repository at this point in the history
hub: add menu item for failed tasks.
  • Loading branch information
rohanpm authored Oct 23, 2023
2 parents ef9ff94 + fb38cf0 commit 327156c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions kobo/admin/templates/hub/menu.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ menu = (
MenuItem("Tasks", "task/index", menu=(
MenuItem("All", "task/index"),
MenuItem("Running", "task/running"),
MenuItem("Failed", "task/failed"),
MenuItem("Finished", "task/finished"),
)),
MenuItem("Info", "worker/list", menu=(
Expand Down
1 change: 1 addition & 0 deletions kobo/hub/urls/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
url(r"^$", TaskListView.as_view(), name="task/index"),
url(r"^(?P<pk>\d+)/$", TaskDetail.as_view(), name="task/detail"),
url(r"^running/$", TaskListView.as_view(state=(TASK_STATES["FREE"], TASK_STATES["ASSIGNED"], TASK_STATES["OPEN"]), title=_("Running tasks"), order_by=["id"]), name="task/running"),
url(r"^failed/$", TaskListView.as_view(state=(TASK_STATES["FAILED"],), title=_("Failed tasks"), order_by=["-dt_created", "id"]), name="task/failed"),
url(r"^finished/$", TaskListView.as_view(state=(TASK_STATES["CLOSED"], TASK_STATES["INTERRUPTED"], TASK_STATES["CANCELED"], TASK_STATES["FAILED"]), title=_("Finished tasks"), order_by=["-dt_created", "id"]), name="task/finished"),
url(r"^(?P<id>\d+)/log/(?P<log_name>.+)$", kobo.hub.views.task_log, name="task/log"),
url(r"^(?P<id>\d+)/log-json/(?P<log_name>.+)$", kobo.hub.views.task_log_json, name="task/log-json"),
Expand Down
9 changes: 9 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ def test_list_running(self):
self.assertTrue(self.task3.method not in str(response.content))
self.assertTrue(self.task4.method not in str(response.content))

def test_list_failed(self):
response = self.client.get('/task/failed/')
self.assertEqual(response.status_code, 200)
# make sure only failed tasks are listed
self.assertTrue(self.task1.get_state_display() not in str(response.content))
self.assertTrue(self.task2.get_state_display() not in str(response.content))
self.assertTrue(self.task3.get_state_display() not in str(response.content))
self.assertTrue(self.task4.get_state_display() in str(response.content))

def test_list_finished(self):
response = self.client.get('/task/finished/')
self.assertEqual(response.status_code, 200)
Expand Down

0 comments on commit 327156c

Please sign in to comment.