def test_reserve_appointment(self, app, client, fake_auth): """Drop-in advisor can reserve an appointment.""" dept_code = 'QCADV' advisor = DropInAdvisor.advisors_for_dept_code(dept_code)[0] user = AuthorizedUser.find_by_id(advisor.authorized_user_id) fake_auth.login(user.uid) waiting = AppointmentTestUtil.create_appointment(client, dept_code) appointment = self._reserve_appointment(client, waiting['id']) assert appointment['status'] == 'reserved' assert appointment['statusDate'] is not None assert appointment['statusBy']['id'] == user.id Appointment.delete(appointment['id'])
def test_appointment_cancel(self, app, client, fake_auth): """Drop-in advisor can cancel appointment.""" dept_code = 'QCADV' advisor = DropInAdvisor.advisors_for_dept_code(dept_code)[0] user = AuthorizedUser.find_by_id(advisor.authorized_user_id) fake_auth.login(user.uid) waiting = AppointmentTestUtil.create_appointment(client, dept_code) appointment = self._cancel_appointment(client, waiting['id'], 'Canceled by wolves') appointment_id = appointment['id'] assert appointment_id == waiting['id'] assert appointment['status'] == 'canceled' assert appointment['statusBy']['id'] == user.id assert appointment['statusBy']['uid'] == user.uid assert appointment['statusDate'] is not None Appointment.delete(appointment_id)
def test_advisor_read_appointment(self, app, client, fake_auth): """L&S advisor reads an appointment.""" fake_auth.login(l_s_college_scheduler_uid) # As scheduler, create appointment appointment = AppointmentTestUtil.create_appointment(client, 'QCADV') appointment_id = appointment['id'] client.get('/api/auth/logout') # Verify unread by advisor uid = l_s_college_advisor_uid user_id = AuthorizedUser.get_id_per_uid(uid) assert AppointmentRead.was_read_by(user_id, appointment_id) is False # Next, log in as advisor and read the appointment fake_auth.login(uid) api_json = self._mark_appointment_read(client, appointment_id) assert api_json['appointmentId'] == appointment_id assert api_json['viewerId'] == user_id assert AppointmentRead.was_read_by(user_id, appointment_id) is True Appointment.delete(appointment_id)
def test_create_appointment_as_coe_scheduler(self, client, fake_auth): """Scheduler can create appointments.""" fake_auth.login(coe_scheduler_uid) details = 'Aloysius has some questions.' appointment = AppointmentTestUtil.create_appointment( client, 'COENG', details) appointment_id = appointment['id'] waitlist = self._get_waitlist(client, 'COENG') matching = next((a for a in waitlist if a['details'] == details), None) assert matching assert appointment_id == matching['id'] assert appointment['read'] is True assert appointment['status'] == 'waiting' assert appointment['student']['sid'] == '3456789012' assert appointment['student']['name'] == 'Paul Kerschen' assert appointment['student']['photoUrl'] assert appointment['appointmentType'] == 'Drop-in' assert len(appointment['topics']) == 2 # Verify that a deleted appointment is off the waitlist Appointment.delete(appointment_id) waitlist = self._get_waitlist(client, 'COENG') assert next( (a for a in waitlist if a['details'] == details), None) is None
def test_steal_appointment_reservation(self, app, client, fake_auth): """Reserve an appointment that another advisor has reserved.""" dept_code = 'COENG' advisor_1 = DropInAdvisor.advisors_for_dept_code(dept_code)[0] user_1 = AuthorizedUser.find_by_id(advisor_1.authorized_user_id) fake_auth.login(user_1.uid) waiting = AppointmentTestUtil.create_appointment(client, dept_code) appointment = self._reserve_appointment(client, waiting['id']) assert appointment['status'] == 'reserved' assert appointment['statusDate'] is not None assert appointment['statusBy']['id'] == user_1.id client.get('/api/auth/logout') # Another advisor comes along... advisor_2 = DropInAdvisor.advisors_for_dept_code(dept_code)[1] user_2 = AuthorizedUser.find_by_id(advisor_2.authorized_user_id) fake_auth.login(user_2.uid) appointment = self._reserve_appointment(client, waiting['id']) assert appointment['status'] == 'reserved' assert appointment['statusDate'] is not None assert appointment['statusBy']['id'] == user_2.id # Clean up Appointment.delete(appointment['id'])