Skip to content

Commit

Permalink
Add tests for /me/appointments
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed Sep 11, 2024
1 parent ebb6d58 commit 4517020
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion backend/test/integration/test_appointment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dateutil.parser

from defines import DAY1, DAY2, DAY3, auth_headers
from defines import DAY1, DAY2, DAY3, auth_headers, TEST_USER_ID


class TestAppointment:
Expand Down Expand Up @@ -70,3 +70,44 @@ def test_get_invitation_ics_file_for_missing_slot(self, with_client, make_appoin
f'/apmt/serve/ics/{generated_appointment.slug}/{generated_appointment.slots[0].id + 1}'
)
assert response.status_code == 404, response.text


class TestMyAppointments:
def test_appointments(self, with_client, make_appointment, make_google_calendar):
appointment_count = 10

calendar = make_google_calendar(subscriber_id=TEST_USER_ID)
appointments = [make_appointment(calendar_id=calendar.id) for _ in range(appointment_count)]

response = with_client.get('/me/appointments', headers=auth_headers)

assert response.status_code == 200, response.text

data = response.json()

assert len(data) == appointment_count

# Should be in order
for index, appointment in enumerate(appointments):
assert appointment.id == data[index]['id']

def test_dont_show_other_subscribers_appointments(self, with_client, make_basic_subscriber, make_appointment, make_google_calendar):
"""Only show my appointments in the /me/appointments route"""
# The other subscriber / appointment
other = make_basic_subscriber()
other_calendar = make_google_calendar(subscriber_id=other.id)
other_appointment = make_appointment(calendar_id=other_calendar.id)

# My Appointment
calendar = make_google_calendar(subscriber_id=TEST_USER_ID)
appointment = make_appointment(calendar_id=calendar.id)

response = with_client.get('/me/appointments', headers=auth_headers)

assert response.status_code == 200, response.text

data = response.json()

assert len(data) == 1
assert other_appointment.id != data[0]['id']
assert appointment.id == data[0]['id']

0 comments on commit 4517020

Please sign in to comment.