Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unit test fail for backend tasks/statistics #6186

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions tests/backend/integration/api/tasks/test_statistics.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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,
},
)
Expand All @@ -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}",
},
)
Expand All @@ -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,
},
)
Expand All @@ -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,
},
)
Expand All @@ -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,
},
)
Expand All @@ -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",
},
)
Expand Down
Loading