Skip to content

Commit

Permalink
add test cases for scenario history and delete API
Browse files Browse the repository at this point in the history
  • Loading branch information
danangmassandy committed Aug 5, 2024
1 parent ec555e3 commit 0a669a9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions django_project/cplus_api/tests/test_scenario_api_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,15 @@ def test_scenario_history(self):
self.assertEqual(len(response.data['results']), 1)
scenario = response.data['results'][0]
self.assertEqual(str(scenario_task.uuid), scenario['uuid'])
# filter completed status only
request = self.factory.get(
reverse('v1:scenario-history') + f'?status={TaskStatus.COMPLETED}'
)
request.resolver_match = FakeResolverMatchV1
request.user = self.user_1
response = view(request)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data['results']), 0)

def test_scenario_detail(self):
view = ScenarioAnalysisTaskDetail.as_view()
Expand All @@ -348,3 +357,14 @@ def test_scenario_detail(self):
response.data['scenario_name'],
scenario_task.detail['scenario_name']
)
# delete scenario
request = self.factory.delete(
reverse('v1:scenario-detail', kwargs=kwargs)
)
request.resolver_match = FakeResolverMatchV1
request.user = self.superuser
response = view(request, **kwargs)
self.assertEqual(response.status_code, 204)
self.assertFalse(ScenarioTask.objects.filter(
id=scenario_task.id
).exists())

0 comments on commit 0a669a9

Please sign in to comment.