Skip to content

Commit c6883b3

Browse files
committed
Amend appointment eligibility to 4 weeks
We send a notification if the appointment date is in 4 weeks or less. Remove the additional 4 days.
1 parent d1e4d53 commit c6883b3

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

manage_breast_screening/notifications/management/commands/send_message_batch.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ def handle(self, *args, **options):
6969
except Exception as e:
7070
raise CommandError(e)
7171

72-
# TODO: Check the appointment notification rules here.
7372
def schedule_date(self) -> datetime:
74-
today = datetime.today()
75-
today_end = today.replace(
76-
hour=23, minute=59, second=59, microsecond=999999, tzinfo=TZ_INFO
77-
)
78-
return today_end + timedelta(weeks=4, days=4)
73+
today = datetime.now(tz=TZ_INFO)
74+
today_end = today.replace(hour=23, minute=59, second=59, microsecond=999999)
75+
return today_end + timedelta(weeks=4)

manage_breast_screening/notifications/tests/management/commands/test_send_message_batch.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ def test_handle_with_appointments_inside_schedule_window(
7474
"""Test that appointments with date inside the schedule period are notified"""
7575
mock_send_message_batch.return_value.status_code = 201
7676
appointment = AppointmentFactory(
77-
starts_at=datetime.now().replace(tzinfo=TZ_INFO)
78-
+ timedelta(weeks=4, days=4)
77+
starts_at=datetime.now().replace(tzinfo=TZ_INFO) + timedelta(weeks=4)
7978
)
8079

8180
subject = Command()
@@ -103,7 +102,7 @@ def test_handle_with_appointments_outside_schedule_window(
103102
"""Test that appointments with date inside the schedule period are notified"""
104103
AppointmentFactory(
105104
starts_at=datetime.now().replace(tzinfo=TZ_INFO)
106-
+ timedelta(weeks=4, days=5)
105+
+ timedelta(weeks=4, days=1)
107106
)
108107

109108
subject = Command()
@@ -153,8 +152,7 @@ def test_handle_with_unrecoverable_failures(
153152
notify_errors = {"errors": [{"some-error": "details"}]}
154153
mock_send_message_batch.return_value.json.return_value = notify_errors
155154
appointment = AppointmentFactory(
156-
starts_at=datetime.now().replace(tzinfo=TZ_INFO)
157-
+ timedelta(weeks=4, days=4)
155+
starts_at=datetime.now().replace(tzinfo=TZ_INFO) + timedelta(weeks=4)
158156
)
159157

160158
Command().handle(**{"routing_plan_id": routing_plan_id})
@@ -179,8 +177,7 @@ def test_handle_with_recoverable_failures(
179177
mock_send_message_batch.return_value.status_code = status_code
180178
mock_send_message_batch.return_value.json.return_value = notify_errors
181179
_appointment = AppointmentFactory(
182-
starts_at=datetime.now().replace(tzinfo=TZ_INFO)
183-
+ timedelta(weeks=4, days=4)
180+
starts_at=datetime.now().replace(tzinfo=TZ_INFO) + timedelta(weeks=4)
184181
)
185182

186183
with patch(

0 commit comments

Comments
 (0)