-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) * Validate booking slot's weekday in schedule timezone. (Fixes #735) * Update backend/src/appointment/routes/schedule.py Co-authored-by: Andreas <[email protected]> * Add some comments to the test --------- Co-authored-by: Andreas <[email protected]>
- Loading branch information
1 parent
996e63d
commit 8094904
Showing
2 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,8 @@ def test_failure(self): | |
|
||
class TestIsAValidBookingTime: | ||
def test_bug_735(self, make_schedule): | ||
"""A test case to cover unsuccessfully capturing bug 735, which is the seemingly random slot not found issue. | ||
Ref: https://github.com/thunderbird/appointment/issues/735""" | ||
# Request data submitted from bug and anonymized. | ||
request_data = { | ||
's_a': { | ||
|
@@ -83,14 +85,43 @@ def test_bug_735(self, make_schedule): | |
end_time=0, # 5PM PDT | ||
timezone='America/Vancouver', | ||
# This is not accurate, but it was probably saved before Nov 3rd. | ||
time_updated=datetime.datetime(2024, 11, 1, 12, 0,0, tzinfo=datetime.UTC), | ||
time_updated=datetime.datetime(2024, 11, 1, 12, 0, 0, tzinfo=datetime.UTC), | ||
) | ||
|
||
# Freeze on the datetime that the error occurred on | ||
with freeze_time('2024-11-04T09:09:29.530Z'): | ||
is_valid = is_this_a_valid_booking_time( | ||
schedule, | ||
s_a.slot | ||
) | ||
is_valid = is_this_a_valid_booking_time(schedule, s_a.slot) | ||
|
||
assert is_valid is True | ||
|
||
def test_bug_735_case_2(self, make_schedule): | ||
"""A test case to cover successfully capturing bug 735, which is the seemingly random slot not found issue. | ||
Ref: https://github.com/thunderbird/appointment/issues/735""" | ||
# Request data submitted from bug and anonymized. | ||
request_data = { | ||
's_a': { | ||
'slot': {'start': '2024-11-17T22:00:00.000Z', 'duration': 30}, | ||
'attendee': {'name': 'melissa', 'email': '[email protected]', 'timezone': 'Australia/Sydney'}, | ||
}, | ||
'url': 'http://localhost:8080/user/username/example/', | ||
} | ||
|
||
s_a = schemas.AvailabilitySlotAttendee(**request_data['s_a']) | ||
|
||
schedule = make_schedule( | ||
active=True, | ||
start_date=datetime.date(2024, 11, 7), | ||
end_date=None, | ||
earliest_booking=0, | ||
farthest_booking=10080, | ||
weekdays=[1, 2, 3, 4, 5], | ||
slot_duration=30, | ||
start_time="22:00", # 9AM AEDT | ||
end_time="06:00", # 5PM AEDT | ||
timezone='Australia/Sydney', | ||
time_updated=datetime.datetime(2024, 11, 15, 12, 0, 0, tzinfo=datetime.UTC), | ||
) | ||
|
||
is_valid = is_this_a_valid_booking_time(schedule, s_a.slot) | ||
|
||
assert is_valid is True |