Skip to content

Commit

Permalink
GET /api/v2/cases/{case_identifier}/tasks return [] data field when t…
Browse files Browse the repository at this point in the history
…here are no tasks
  • Loading branch information
c8y3 committed Jan 24, 2025
1 parent 54b2cb4 commit e9c5947
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 1 addition & 6 deletions source/app/blueprints/rest/v2/cases/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,8 @@ def case_get_tasks(case_identifier):

tasks = get_tasks(case_identifier)

if not tasks:
output = []
else:
output = tasks

result = {
'tasks': output,
'data': tasks
}

return response_api_success(result)
Expand Down
7 changes: 6 additions & 1 deletion tests/tests_rest_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,9 @@ def test_update_task_should_return_a_task(self):
def test_get_tasks_should_return_200(self):
case_identifier = self._subject.create_dummy_case()
response = self._subject.get(f'/api/v2/cases/{case_identifier}/tasks')
self.assertEqual(200, response.status_code)
self.assertEqual(200, response.status_code)

def test_get_tasks_should_return_empty_list_for_field_data_when_there_are_no_tasks(self):
case_identifier = self._subject.create_dummy_case()
response = self._subject.get(f'/api/v2/cases/{case_identifier}/tasks').json()
self.assertEqual([], response['data'])

0 comments on commit e9c5947

Please sign in to comment.