diff --git a/tests/backend/integration/api/tasks/test_statistics.py b/tests/backend/integration/api/tasks/test_statistics.py index 27134a9e0e..4e53d1c4fe 100644 --- a/tests/backend/integration/api/tasks/test_statistics.py +++ b/tests/backend/integration/api/tasks/test_statistics.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timedelta from backend.models.postgis.task import Task, TaskStatus from backend.services.campaign_service import CampaignService, CampaignProjectDTO @@ -105,7 +105,11 @@ def test_returns_200_if_valid_date_range(self): response = self.client.get( self.url, headers={"Authorization": self.user_session_token}, - query_string={"startDate": "2023-01-01"}, + query_string={ + "startDate": (datetime.now() - timedelta(days=6 * 30)).strftime( + "%Y-%m-%d" + ) + }, ) # Assert self.assertEqual(response.status_code, 200) @@ -130,7 +134,9 @@ def test_filters_task_by_project(self): self.url, headers={"Authorization": self.user_session_token}, query_string={ - "startDate": "2023-01-01", + "startDate": (datetime.now() - timedelta(days=6 * 30)).strftime( + "%Y-%m-%d" + ), "projectId": self.test_project_1.id, }, ) @@ -152,7 +158,9 @@ def test_filters_by_multiple_projects(self): self.url, headers={"Authorization": self.user_session_token}, query_string={ - "startDate": "2023-01-01", + "startDate": (datetime.now() - timedelta(days=6 * 30)).strftime( + "%Y-%m-%d" + ), "projectId": f"{self.test_project_1.id}, {self.test_project_2.id}", }, ) @@ -173,7 +181,9 @@ def test_filters_by_organisation_id(self): self.url, headers={"Authorization": self.user_session_token}, query_string={ - "startDate": "2023-01-01", + "startDate": (datetime.now() - timedelta(days=6 * 30)).strftime( + "%Y-%m-%d" + ), "organisationId": test_organisation.id, }, ) @@ -194,7 +204,9 @@ def test_filters_by_organisation_name(self): self.url, headers={"Authorization": self.user_session_token}, query_string={ - "startDate": "2023-01-01", + "startDate": (datetime.now() - timedelta(days=6 * 30)).strftime( + "%Y-%m-%d" + ), "organisationName": test_organisation.name, }, ) @@ -217,7 +229,9 @@ def test_filters_by_campaign(self): self.url, headers={"Authorization": self.user_session_token}, query_string={ - "startDate": "2023-01-01", + "startDate": (datetime.now() - timedelta(days=6 * 30)).strftime( + "%Y-%m-%d" + ), "campaign": test_campaign.name, }, ) @@ -239,7 +253,9 @@ def test_filters_by_country(self): self.url, headers={"Authorization": self.user_session_token}, query_string={ - "startDate": "2023-01-01", + "startDate": (datetime.now() - timedelta(days=6 * 30)).strftime( + "%Y-%m-%d" + ), "country": "Nepal", }, )