Skip to content

Commit

Permalink
Add a test for bug #735
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed Nov 6, 2024
1 parent 1e0f471 commit 536768e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
4 changes: 3 additions & 1 deletion backend/test/factory/schedule_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def _make_schedule(
meeting_link_provider=models.MeetingLinkProviderType.none,
slug=FAKER_RANDOM_VALUE,
booking_confirmation=True,
timezone='UTC'
timezone='UTC',
time_updated=None,
):
with with_db() as db:
return repo.schedule.create(
Expand Down Expand Up @@ -54,6 +55,7 @@ def _make_schedule(
if factory_has_value(calendar_id)
else make_caldav_calendar(connected=True).id,
timezone=timezone,
time_updated=time_updated,
),
)

Expand Down
45 changes: 44 additions & 1 deletion backend/test/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import pytest
import datetime

from freezegun import freeze_time

from appointment.database import schemas
from appointment.routes.schedule import is_this_a_valid_booking_time
from appointment.utils import retrieve_user_url_data


Expand Down Expand Up @@ -51,3 +56,41 @@ def test_failure(self):
assert original_username != username
assert original_signature != signature
assert original_clean_url != clean_url


class TestIsAValidBookingTime:
def test_bug_735(self, make_schedule):
# Request data submitted from bug and anonymized.
request_data = {
's_a': {
'attendee': {'email': '[email protected]', 'name': 'Email Example', 'timezone': 'Europe/London'},
'slot': {'duration': 45, 'start': '2024-11-11T17:00:00.000Z'},
},
'url': 'https://appointment.day/user/fake/example/',
}

s_a = schemas.AvailabilitySlotAttendee(**request_data['s_a'])

schedule = make_schedule(
active=True,
start_date=datetime.date(2024, 11, 1),
end_date=None,
earliest_booking=2880,
farthest_booking=10080,
weekdays=[1, 2, 3, 4, 5],
slot_duration=45,
start_time=17,
end_time=0,
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),
)

# 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
)

assert is_valid is True

0 comments on commit 536768e

Please sign in to comment.