Skip to content

Commit

Permalink
chore: add test for views
Browse files Browse the repository at this point in the history
  • Loading branch information
luisfelipec95 committed Mar 3, 2025
1 parent 72dc4e8 commit 6471130
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions eox_core/api/data/aggregated_collector/v1/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,21 @@ def test_aggregated_collector_view(self, mock_task):
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)

mock_task.assert_called_once()

def test_aggregated_collector_view_disabled(self):
"""
Test that the view returns 503 if the API is disabled.
"""
settings.AGGREGATED_DATA_COLLECTOR_API_ENABLED = False

response = self.client.post(self.url, HTTP_AUTHORIZATION=f"Bearer {settings.EOX_CORE_AGGREGATED_COLLECTOR_AUTH_TOKEN}")

self.assertEqual(response.status_code, status.HTTP_503_SERVICE_UNAVAILABLE)

def test_aggregated_collector_view_no_auth(self):
"""
Test that the view returns 401 if no authentication token is provided.
"""
response = self.client.post(self.url)

self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)

0 comments on commit 6471130

Please sign in to comment.