From fc485e690997ce1fec3e87e68658a2dfc552e1e9 Mon Sep 17 00:00:00 2001 From: Henry Cooksley Date: Mon, 22 Jan 2024 14:00:12 +0000 Subject: [PATCH 1/7] Add property open_working_days --- api/cases/models.py | 7 +++++++ api/cases/serializers.py | 1 + 2 files changed, 8 insertions(+) diff --git a/api/cases/models.py b/api/cases/models.py index f1cb2e0de8..1d032066fe 100644 --- a/api/cases/models.py +++ b/api/cases/models.py @@ -29,6 +29,7 @@ from api.cases.libraries.reference_code import generate_reference_code from api.cases.managers import CaseManager, CaseReferenceCodeManager, AdviceManager from api.common.models import TimestampableModel, CreatedAt +from api.common.dates import working_days_in_range from api.core.constants import GovPermissions from api.core.permissions import assert_user_has_permission from api.documents.models import Document @@ -638,6 +639,12 @@ def is_manually_closed(self): def is_query_closed(self, lookup, value): return ~Q(responded_at__isnull=value) + @property + def open_working_days(self): + start_date = self.created_at + end_date = self.responded_at if self.responded_at else timezone.now() + return working_days_in_range(start_date=start_date, end_date=end_date) + notifications = GenericRelation(ExporterNotification, related_query_name="ecju_query") def save(self, *args, **kwargs): diff --git a/api/cases/serializers.py b/api/cases/serializers.py index f104057802..de07bc1a29 100644 --- a/api/cases/serializers.py +++ b/api/cases/serializers.py @@ -576,6 +576,7 @@ class Meta: "documents", "is_query_closed", "is_manually_closed", + "open_working_days", ) def get_raised_by_user_name(self, instance): From 1ad75e55bbcb9a27280abca9d06aca80ac0eafb5 Mon Sep 17 00:00:00 2001 From: Henry Cooksley Date: Mon, 22 Jan 2024 15:25:32 +0000 Subject: [PATCH 2/7] Fix working_days_in_range function --- api/common/dates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/common/dates.py b/api/common/dates.py index 710e630e7e..7bc7c23efa 100644 --- a/api/common/dates.py +++ b/api/common/dates.py @@ -28,7 +28,7 @@ def is_weekend(date): def working_days_in_range(start_date, end_date): dates_in_range = [start_date + timedelta(n) for n in range((end_date - start_date).days)] - return len([date for date in dates_in_range if not is_bank_holiday(date) or not is_weekend(date)]) + return len([date for date in dates_in_range if (not is_bank_holiday(date) and not is_weekend(date))]) def working_hours_in_range(start_date, end_date): From 583bae199339825ed416624c1735624bbd2c6eed Mon Sep 17 00:00:00 2001 From: Henry Cooksley Date: Mon, 22 Jan 2024 15:51:20 +0000 Subject: [PATCH 3/7] Add tests for open_working_days --- api/cases/tests/test_case_ecju_queries.py | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/api/cases/tests/test_case_ecju_queries.py b/api/cases/tests/test_case_ecju_queries.py index d62a524794..1fcb5c0584 100644 --- a/api/cases/tests/test_case_ecju_queries.py +++ b/api/cases/tests/test_case_ecju_queries.py @@ -13,6 +13,7 @@ from api.audit_trail.serializers import AuditSerializer from api.cases.enums import ECJUQueryType from api.cases.models import EcjuQuery +from api.common.dates import working_days_in_range from api.compliance.tests.factories import ComplianceSiteCaseFactory, ComplianceVisitCaseFactory from api.licences.enums import LicenceStatus from api.picklists.enums import PicklistType @@ -224,6 +225,47 @@ def test_ecju_query_open_query_count_responded_return_zero(self): self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertEqual(0, response_data["count"]) + def test_ecju_query_shows_correct_open_working_days_for_open_query(self): + case = self.create_standard_application_case(self.organisation) + created_at_datetime = timezone.datetime(2024, 1, 1, 12, 30, 0, 123456, tzinfo=timezone.now().tzinfo) + ecju_query = EcjuQueryFactory( + question="this is the question", + response=None, + responded_at=None, + case=case, + created_at=created_at_datetime, + ) + + url = reverse("cases:case_ecju_queries", kwargs={"pk": case.id}) + + response = self.client.get(url, **self.gov_headers) + response_data = response.json() + + assert response_data["ecju_queries"][0]["open_working_days"] == working_days_in_range( + created_at_datetime, timezone.now() + ) + + def test_ecju_query_shows_correct_open_working_days_for_closed_query(self): + case = self.create_standard_application_case(self.organisation) + created_at_datetime = timezone.datetime(2024, 1, 1, 12, 30, 0, 123456, tzinfo=timezone.now().tzinfo) + responded_at_datetime = timezone.datetime(2024, 1, 18, 12, 30, 0, 123456, tzinfo=timezone.now().tzinfo) + ecju_query = EcjuQueryFactory( + question="this is the question", + response="some response text", + responded_at=responded_at_datetime, + case=case, + created_at=created_at_datetime, + ) + + url = reverse("cases:case_ecju_queries", kwargs={"pk": case.id}) + + response = self.client.get(url, **self.gov_headers) + response_data = response.json() + + assert response_data["ecju_queries"][0]["open_working_days"] == working_days_in_range( + created_at_datetime, responded_at_datetime + ) + class ECJUQueriesCreateTest(DataTestClient): @parameterized.expand([ECJUQueryType.ECJU, ECJUQueryType.PRE_VISIT_QUESTIONNAIRE, ECJUQueryType.COMPLIANCE_ACTIONS]) From 690498b589f0e3b00a9e015e541e9a691d35160c Mon Sep 17 00:00:00 2001 From: Henry Cooksley Date: Mon, 22 Jan 2024 16:01:56 +0000 Subject: [PATCH 4/7] Add test for working_days_in_range --- api/common/tests/test_dates.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/api/common/tests/test_dates.py b/api/common/tests/test_dates.py index 1d88ef7a24..263235b760 100644 --- a/api/common/tests/test_dates.py +++ b/api/common/tests/test_dates.py @@ -2,9 +2,14 @@ from django.utils.datetime_safe import date, datetime from parameterized import parameterized -import requests_mock - -from api.common.dates import is_weekend, is_bank_holiday, number_of_days_since, working_hours_in_range, BANK_HOLIDAY_API +from api.common.dates import ( + is_weekend, + is_bank_holiday, + number_of_days_since, + working_hours_in_range, + BANK_HOLIDAY_API, + working_days_in_range, +) from test_helpers.clients import DataTestClient @@ -424,3 +429,9 @@ def test_num_working_hours_over_working_days_weekends_bank_holidays(self): result = working_hours_in_range(start_date, end_date) self.assertEqual(result, expected_result) + + def test_working_days_in_range(self): + start_date = datetime(2023, 12, 22, 12, 30, 0, 123456) + end_date = datetime(2024, 1, 22, 12, 30, 0, 123456) + + self.assertEqual(working_days_in_range(start_date, end_date), 18) From 780f429f12eee9fe77aec86423592c763a430b64 Mon Sep 17 00:00:00 2001 From: Henry Cooksley Date: Wed, 24 Jan 2024 13:48:34 +0000 Subject: [PATCH 5/7] Refactor working days functions --- api/cases/helpers.py | 8 ++++++++ api/cases/models.py | 2 +- api/cases/tests/test_case_ecju_queries.py | 2 +- api/cases/tests/test_helpers.py | 11 +++++++++++ api/common/dates.py | 11 ++++++++++- api/common/tests/test_dates.py | 17 +++-------------- 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/api/cases/helpers.py b/api/cases/helpers.py index 208d14b526..3bfeb801d5 100644 --- a/api/cases/helpers.py +++ b/api/cases/helpers.py @@ -1,3 +1,6 @@ +from datetime import timedelta + +from api.common.dates import is_bank_holiday, is_weekend from api.cases.enums import CaseTypeReferenceEnum from api.staticdata.statuses.enums import CaseStatusEnum from api.users.models import GovUser, GovNotification @@ -73,3 +76,8 @@ def can_set_status(case, status): return False return True + + +def working_days_in_range(start_date, end_date): + dates_in_range = [start_date + timedelta(n) for n in range((end_date - start_date).days)] + return len([date for date in dates_in_range if (not is_bank_holiday(date) and not is_weekend(date))]) diff --git a/api/cases/models.py b/api/cases/models.py index 1d032066fe..0da8745ddb 100644 --- a/api/cases/models.py +++ b/api/cases/models.py @@ -26,10 +26,10 @@ AdviceLevel, EnforcementXMLEntityTypes, ) +from api.cases.helpers import working_days_in_range from api.cases.libraries.reference_code import generate_reference_code from api.cases.managers import CaseManager, CaseReferenceCodeManager, AdviceManager from api.common.models import TimestampableModel, CreatedAt -from api.common.dates import working_days_in_range from api.core.constants import GovPermissions from api.core.permissions import assert_user_has_permission from api.documents.models import Document diff --git a/api/cases/tests/test_case_ecju_queries.py b/api/cases/tests/test_case_ecju_queries.py index 1fcb5c0584..019a0d9cfa 100644 --- a/api/cases/tests/test_case_ecju_queries.py +++ b/api/cases/tests/test_case_ecju_queries.py @@ -13,7 +13,7 @@ from api.audit_trail.serializers import AuditSerializer from api.cases.enums import ECJUQueryType from api.cases.models import EcjuQuery -from api.common.dates import working_days_in_range +from api.cases.helpers import working_days_in_range from api.compliance.tests.factories import ComplianceSiteCaseFactory, ComplianceVisitCaseFactory from api.licences.enums import LicenceStatus from api.picklists.enums import PicklistType diff --git a/api/cases/tests/test_helpers.py b/api/cases/tests/test_helpers.py index 6aa60b73d6..4e0d9c87b5 100644 --- a/api/cases/tests/test_helpers.py +++ b/api/cases/tests/test_helpers.py @@ -1 +1,12 @@ # TODO; test notify_ecju_query in total isolation + +import datetime + +from api.cases.helpers import working_days_in_range + + +def test_working_days_in_range(): + start_date = datetime.datetime(2023, 12, 22, 12, 30, 0, 123456) + end_date = datetime.datetime(2024, 1, 22, 12, 30, 0, 123456) + + assert working_days_in_range(start_date, end_date) == 18 diff --git a/api/common/dates.py b/api/common/dates.py index 7bc7c23efa..1042b0190e 100644 --- a/api/common/dates.py +++ b/api/common/dates.py @@ -27,8 +27,17 @@ def is_weekend(date): def working_days_in_range(start_date, end_date): + """ + This function does not work as intended and should not be used, please see + LTD-4628 for more information. + + This is because of the predicate used in the list + comprehension, which incorrectly returns True early. An example fix is to replace the list comprehension + with `[date for date in dates_in_range if (not is_bank_holiday(date) and not is_weekend(date))]` + but this should be done and released at the same time as the other fixes in LTD-4628. + """ dates_in_range = [start_date + timedelta(n) for n in range((end_date - start_date).days)] - return len([date for date in dates_in_range if (not is_bank_holiday(date) and not is_weekend(date))]) + return len([date for date in dates_in_range if not is_bank_holiday(date) or not is_weekend(date)]) def working_hours_in_range(start_date, end_date): diff --git a/api/common/tests/test_dates.py b/api/common/tests/test_dates.py index 263235b760..1d88ef7a24 100644 --- a/api/common/tests/test_dates.py +++ b/api/common/tests/test_dates.py @@ -2,14 +2,9 @@ from django.utils.datetime_safe import date, datetime from parameterized import parameterized -from api.common.dates import ( - is_weekend, - is_bank_holiday, - number_of_days_since, - working_hours_in_range, - BANK_HOLIDAY_API, - working_days_in_range, -) +import requests_mock + +from api.common.dates import is_weekend, is_bank_holiday, number_of_days_since, working_hours_in_range, BANK_HOLIDAY_API from test_helpers.clients import DataTestClient @@ -429,9 +424,3 @@ def test_num_working_hours_over_working_days_weekends_bank_holidays(self): result = working_hours_in_range(start_date, end_date) self.assertEqual(result, expected_result) - - def test_working_days_in_range(self): - start_date = datetime(2023, 12, 22, 12, 30, 0, 123456) - end_date = datetime(2024, 1, 22, 12, 30, 0, 123456) - - self.assertEqual(working_days_in_range(start_date, end_date), 18) From 0a0e56df38beb85ed2d318c7409b4bc6cb320d01 Mon Sep 17 00:00:00 2001 From: Henry Cooksley Date: Mon, 29 Jan 2024 13:59:39 +0000 Subject: [PATCH 6/7] Refactor tests --- api/cases/models.py | 1 - api/cases/tests/test_case_ecju_queries.py | 124 +++++++++++++++++++--- api/cases/tests/test_helpers.py | 55 +++++++++- 3 files changed, 161 insertions(+), 19 deletions(-) diff --git a/api/cases/models.py b/api/cases/models.py index 0da8745ddb..a0c70d545b 100644 --- a/api/cases/models.py +++ b/api/cases/models.py @@ -628,7 +628,6 @@ def is_query_closed(self): @queryable_property def is_manually_closed(self): - if self.responded_by_user and self.responded_by_user.type == UserType.INTERNAL: return True else: diff --git a/api/cases/tests/test_case_ecju_queries.py b/api/cases/tests/test_case_ecju_queries.py index 019a0d9cfa..76e4061ca8 100644 --- a/api/cases/tests/test_case_ecju_queries.py +++ b/api/cases/tests/test_case_ecju_queries.py @@ -1,4 +1,5 @@ from unittest import mock +from datetime import timedelta from django.urls import reverse from django.utils import timezone @@ -13,7 +14,6 @@ from api.audit_trail.serializers import AuditSerializer from api.cases.enums import ECJUQueryType from api.cases.models import EcjuQuery -from api.cases.helpers import working_days_in_range from api.compliance.tests.factories import ComplianceSiteCaseFactory, ComplianceVisitCaseFactory from api.licences.enums import LicenceStatus from api.picklists.enums import PicklistType @@ -225,9 +225,54 @@ def test_ecju_query_open_query_count_responded_return_zero(self): self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertEqual(0, response_data["count"]) - def test_ecju_query_shows_correct_open_working_days_for_open_query(self): + @parameterized.expand( + [ + ( + { + "year": 2022, + "month": 11, + "day": 30, + "hour": 9, + "minute": 50, + "second": 0, + "microsecond": 123456, + "tzinfo": timezone.utc, + }, + 291, + ), + ( + { + "year": 2023, + "month": 12, + "day": 15, + "hour": 13, + "minute": 37, + "second": 0, + "microsecond": 123456, + "tzinfo": timezone.utc, + }, + 28, + ), + ( + { + "year": 2024, + "month": 1, + "day": 1, + "hour": 12, + "minute": 30, + "second": 0, + "microsecond": 123456, + "tzinfo": timezone.utc, + }, + 19, + ), + ] + ) + def test_ecju_query_shows_correct_open_working_days_for_open_query( + self, created_at_datetime_kwargs, expected_working_days + ): case = self.create_standard_application_case(self.organisation) - created_at_datetime = timezone.datetime(2024, 1, 1, 12, 30, 0, 123456, tzinfo=timezone.now().tzinfo) + created_at_datetime = timezone.datetime(**created_at_datetime_kwargs) ecju_query = EcjuQueryFactory( question="this is the question", response=None, @@ -238,17 +283,70 @@ def test_ecju_query_shows_correct_open_working_days_for_open_query(self): url = reverse("cases:case_ecju_queries", kwargs={"pk": case.id}) - response = self.client.get(url, **self.gov_headers) - response_data = response.json() - - assert response_data["ecju_queries"][0]["open_working_days"] == working_days_in_range( - created_at_datetime, timezone.now() + # for open queries there is no responded_at datetime + # and timezone.now() is used as the end date so + # this must be mocked to write a static test + mock_now = timezone.datetime( + year=2024, month=1, day=29, hour=13, minute=40, second=0, microsecond=0, tzinfo=timezone.utc ) + with mock.patch("django.utils.timezone.now", return_value=mock_now): + response = self.client.get(url, **self.gov_headers) + response_data = response.json() - def test_ecju_query_shows_correct_open_working_days_for_closed_query(self): + assert response_data["ecju_queries"][0]["open_working_days"] == expected_working_days + + @parameterized.expand( + [ + ( + { + "year": 2022, + "month": 11, + "day": 30, + "hour": 9, + "minute": 50, + "second": 0, + "microsecond": 123456, + "tzinfo": timezone.utc, + }, + 365, + 252, + ), + ( + { + "year": 2023, + "month": 12, + "day": 15, + "hour": 13, + "minute": 37, + "second": 0, + "microsecond": 123456, + "tzinfo": timezone.utc, + }, + 30, + 18, + ), + ( + { + "year": 2024, + "month": 1, + "day": 28, + "hour": 12, + "minute": 6, + "second": 0, + "microsecond": 123456, + "tzinfo": timezone.utc, + }, + 1, + 0, + ), + ], + ) + def test_ecju_query_shows_correct_open_working_days_for_closed_query( + self, created_at_datetime_kwargs, timedelta_days, expected_working_days + ): case = self.create_standard_application_case(self.organisation) - created_at_datetime = timezone.datetime(2024, 1, 1, 12, 30, 0, 123456, tzinfo=timezone.now().tzinfo) - responded_at_datetime = timezone.datetime(2024, 1, 18, 12, 30, 0, 123456, tzinfo=timezone.now().tzinfo) + created_at_datetime = timezone.datetime(**created_at_datetime_kwargs) + responded_at_datetime = created_at_datetime + timedelta(days=timedelta_days) ecju_query = EcjuQueryFactory( question="this is the question", response="some response text", @@ -262,9 +360,7 @@ def test_ecju_query_shows_correct_open_working_days_for_closed_query(self): response = self.client.get(url, **self.gov_headers) response_data = response.json() - assert response_data["ecju_queries"][0]["open_working_days"] == working_days_in_range( - created_at_datetime, responded_at_datetime - ) + assert response_data["ecju_queries"][0]["open_working_days"] == expected_working_days class ECJUQueriesCreateTest(DataTestClient): diff --git a/api/cases/tests/test_helpers.py b/api/cases/tests/test_helpers.py index 4e0d9c87b5..c4ead5e371 100644 --- a/api/cases/tests/test_helpers.py +++ b/api/cases/tests/test_helpers.py @@ -1,12 +1,59 @@ # TODO; test notify_ecju_query in total isolation import datetime +from parameterized import parameterized from api.cases.helpers import working_days_in_range -def test_working_days_in_range(): - start_date = datetime.datetime(2023, 12, 22, 12, 30, 0, 123456) - end_date = datetime.datetime(2024, 1, 22, 12, 30, 0, 123456) +@parameterized.expand( + [ + ( + { + "year": 2022, + "month": 11, + "day": 30, + "hour": 9, + "minute": 50, + "second": 0, + "microsecond": 123456, + "tzinfo": datetime.timezone.utc, + }, + 365, + 252, + ), + ( + { + "year": 2023, + "month": 12, + "day": 15, + "hour": 13, + "minute": 37, + "second": 0, + "microsecond": 123456, + "tzinfo": datetime.timezone.utc, + }, + 30, + 18, + ), + ( + { + "year": 2024, + "month": 1, + "day": 28, + "hour": 12, + "minute": 6, + "second": 0, + "microsecond": 123456, + "tzinfo": datetime.timezone.utc, + }, + 1, + 0, + ), + ], +) +def test_working_days_in_range(created_at_datetime_kwargs, timedelta_days, expected_working_days): + start_date = datetime.datetime(**created_at_datetime_kwargs) + end_date = start_date + datetime.timedelta(days=timedelta_days) - assert working_days_in_range(start_date, end_date) == 18 + assert working_days_in_range(start_date, end_date) == expected_working_days From a6345d5172a5c9a95f5c7602b692fd8b51eb9071 Mon Sep 17 00:00:00 2001 From: Henry Cooksley Date: Mon, 29 Jan 2024 15:50:21 +0000 Subject: [PATCH 7/7] Refactor tests --- api/cases/tests/test_case_ecju_queries.py | 29 ++++++----------------- api/cases/tests/test_helpers.py | 11 +++------ 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/api/cases/tests/test_case_ecju_queries.py b/api/cases/tests/test_case_ecju_queries.py index 76e4061ca8..e6ae807d1d 100644 --- a/api/cases/tests/test_case_ecju_queries.py +++ b/api/cases/tests/test_case_ecju_queries.py @@ -7,6 +7,7 @@ from faker import Faker from parameterized import parameterized from rest_framework import status +from freezegun import freeze_time from api.applications.models import BaseApplication from api.audit_trail.enums import AuditType @@ -234,8 +235,6 @@ def test_ecju_query_open_query_count_responded_return_zero(self): "day": 30, "hour": 9, "minute": 50, - "second": 0, - "microsecond": 123456, "tzinfo": timezone.utc, }, 291, @@ -247,8 +246,6 @@ def test_ecju_query_open_query_count_responded_return_zero(self): "day": 15, "hour": 13, "minute": 37, - "second": 0, - "microsecond": 123456, "tzinfo": timezone.utc, }, 28, @@ -260,14 +257,14 @@ def test_ecju_query_open_query_count_responded_return_zero(self): "day": 1, "hour": 12, "minute": 30, - "second": 0, - "microsecond": 123456, "tzinfo": timezone.utc, }, 19, ), + ({"year": 2024, "month": 1, "day": 22, "hour": 15, "minute": 40, "tzinfo": timezone.utc}, 5), ] ) + @freeze_time("2024-01-29 15:00:00") def test_ecju_query_shows_correct_open_working_days_for_open_query( self, created_at_datetime_kwargs, expected_working_days ): @@ -283,14 +280,7 @@ def test_ecju_query_shows_correct_open_working_days_for_open_query( url = reverse("cases:case_ecju_queries", kwargs={"pk": case.id}) - # for open queries there is no responded_at datetime - # and timezone.now() is used as the end date so - # this must be mocked to write a static test - mock_now = timezone.datetime( - year=2024, month=1, day=29, hour=13, minute=40, second=0, microsecond=0, tzinfo=timezone.utc - ) - with mock.patch("django.utils.timezone.now", return_value=mock_now): - response = self.client.get(url, **self.gov_headers) + response = self.client.get(url, **self.gov_headers) response_data = response.json() assert response_data["ecju_queries"][0]["open_working_days"] == expected_working_days @@ -304,8 +294,6 @@ def test_ecju_query_shows_correct_open_working_days_for_open_query( "day": 30, "hour": 9, "minute": 50, - "second": 0, - "microsecond": 123456, "tzinfo": timezone.utc, }, 365, @@ -318,13 +306,12 @@ def test_ecju_query_shows_correct_open_working_days_for_open_query( "day": 15, "hour": 13, "minute": 37, - "second": 0, - "microsecond": 123456, "tzinfo": timezone.utc, }, 30, 18, ), + ({"year": 2024, "month": 1, "day": 22, "hour": 15, "minute": 40, "tzinfo": timezone.utc}, 7, 5), ( { "year": 2024, @@ -332,8 +319,6 @@ def test_ecju_query_shows_correct_open_working_days_for_open_query( "day": 28, "hour": 12, "minute": 6, - "second": 0, - "microsecond": 123456, "tzinfo": timezone.utc, }, 1, @@ -342,11 +327,11 @@ def test_ecju_query_shows_correct_open_working_days_for_open_query( ], ) def test_ecju_query_shows_correct_open_working_days_for_closed_query( - self, created_at_datetime_kwargs, timedelta_days, expected_working_days + self, created_at_datetime_kwargs, calendar_days, expected_working_days ): case = self.create_standard_application_case(self.organisation) created_at_datetime = timezone.datetime(**created_at_datetime_kwargs) - responded_at_datetime = created_at_datetime + timedelta(days=timedelta_days) + responded_at_datetime = created_at_datetime + timedelta(days=calendar_days) ecju_query = EcjuQueryFactory( question="this is the question", response="some response text", diff --git a/api/cases/tests/test_helpers.py b/api/cases/tests/test_helpers.py index c4ead5e371..f85b5e651a 100644 --- a/api/cases/tests/test_helpers.py +++ b/api/cases/tests/test_helpers.py @@ -15,8 +15,6 @@ "day": 30, "hour": 9, "minute": 50, - "second": 0, - "microsecond": 123456, "tzinfo": datetime.timezone.utc, }, 365, @@ -29,13 +27,12 @@ "day": 15, "hour": 13, "minute": 37, - "second": 0, - "microsecond": 123456, "tzinfo": datetime.timezone.utc, }, 30, 18, ), + ({"year": 2024, "month": 1, "day": 22, "hour": 15, "minute": 40, "tzinfo": datetime.timezone.utc}, 7, 5), ( { "year": 2024, @@ -43,8 +40,6 @@ "day": 28, "hour": 12, "minute": 6, - "second": 0, - "microsecond": 123456, "tzinfo": datetime.timezone.utc, }, 1, @@ -52,8 +47,8 @@ ), ], ) -def test_working_days_in_range(created_at_datetime_kwargs, timedelta_days, expected_working_days): +def test_working_days_in_range(created_at_datetime_kwargs, calendar_days, expected_working_days): start_date = datetime.datetime(**created_at_datetime_kwargs) - end_date = start_date + datetime.timedelta(days=timedelta_days) + end_date = start_date + datetime.timedelta(days=calendar_days) assert working_days_in_range(start_date, end_date) == expected_working_days