Example #1
0
    def setUpClass(cls):
        super().setUpClass()

        # dev appointments - no link default to not have links and require notifications (e.g. phone appointment)
        cls.at4 = app.AppointmentType(
            ddb_client=cls.aa1._ddb_client,
            acuity_client=cls.aa1._acuity_client,
            logger=cls.logger,
        )
        cls.at4.from_dict({
            "type_id":
            cls.test_data["dev_appointment_no_link_type_id"],
            "has_link":
            False,
            "send_notifications":
            True,
            "project_task_id":
            cls.test_data["project_task_id"],
        })
        cls.at4.get_appointment_type_info_from_acuity()
        cls.at4.ddb_dump(update_allowed=True)

        cls.ae = app.AcuityEvent(
            acuity_event=cls.test_data["event_body"],
            logger=cls.logger,
        )
Example #2
0
 def test_05_notify_thiscovery_team_aborted_past_appointment(self):
     ae = app.AcuityEvent(
         acuity_event=self.test_data["past_appointment_event_body"],
         logger=self.logger,
     )
     result = ae.notify_thiscovery_team()
     self.assertEqual("aborted", result)
Example #3
0
 def test_11_process_rescheduling_same_calendar_ok_link_already_generated(
         self):
     original_appointment = copy.copy(self.aa1)
     original_appointment.link = td["interview_url"]
     original_appointment.ddb_dump(
         update_allowed=True)  # store original appointment in ddb
     event_body = (
         f"action=appointment.rescheduled"
         f"&id=399682887&calendarID=4038206"
         f"&appointmentTypeID={self.test_data['test_appointment_type_id']}")
     ae = app.AcuityEvent(acuity_event=event_body, logger=self.logger)
     (
         storing_result,
         task_completion_result,
         thiscovery_team_notification_result,
         participant_and_researchers_notification_results,
     ) = ae.process()
     self.assertEqual(HTTPStatus.OK,
                      storing_result["ResponseMetadata"]["HTTPStatusCode"])
     self.assertIsNone(task_completion_result)
     self.assertIsNone(thiscovery_team_notification_result)
     participant_result = participant_and_researchers_notification_results.get(
         "participant")
     self.assertEqual(HTTPStatus.NO_CONTENT, participant_result)
     researchers_result = participant_and_researchers_notification_results.get(
         "researchers")
     self.assertEqual([HTTPStatus.NO_CONTENT] * 2, researchers_result)
Example #4
0
 def test_09_process_booking_no_link_with_notifications_no_user_metadata_ok(
         self):
     event_body = (
         f"action=appointment.scheduled"
         f"&id=399682887&calendarID=4038206"
         f"&appointmentTypeID={self.test_data['dev_appointment_no_link_type_id']}"
     )
     ae = app.AcuityEvent(acuity_event=event_body, logger=self.logger)
     (
         storing_result,
         task_completion_result,
         thiscovery_team_notification_result,
         participant_and_researchers_notification_results,
     ) = ae.process()
     self.assertEqual(HTTPStatus.OK,
                      storing_result["ResponseMetadata"]["HTTPStatusCode"])
     self.assertIsNone(task_completion_result)
     self.assertIsNone(thiscovery_team_notification_result)
     participant_result = participant_and_researchers_notification_results.get(
         "participant")
     self.assertEqual(HTTPStatus.NO_CONTENT, participant_result)
     researchers_result = participant_and_researchers_notification_results.get(
         "researchers")
     self.assertEqual([HTTPStatus.NO_CONTENT] * 2, researchers_result)
     self.clear_appointments_table()
Example #5
0
 def test_03_init_fail_invalid_appointment_type_id(self):
     invalid_id = "invalid_id"
     event_body = (f"action=appointment.scheduled"
                   f"&id=399682887&calendarID=4038206"
                   f"&appointmentTypeID={invalid_id}")
     with self.assertRaises(AttributeError):
         app.AcuityEvent(
             acuity_event=event_body,
             logger=self.logger,
         )
Example #6
0
 def test_02_init_fail_non_existent_appointment_type_id(self):
     non_existent_id = "123456789"
     event_body = (f"action=appointment.scheduled"
                   f"&id=399682887&calendarID=4038206"
                   f"&appointmentTypeID={non_existent_id}")
     with self.assertRaises(utils.ObjectDoesNotExistError):
         app.AcuityEvent(
             acuity_event=event_body,
             logger=self.logger,
         )
Example #7
0
 def test_07_process_booking_has_link_with_user_metadata_ok(self):
     ae = app.AcuityEvent(
         acuity_event=self.test_data["event_body_with_user_metadata"],
         logger=self.logger,
     )
     (
         storing_result,
         task_completion_result,
         thiscovery_team_notification_result,
         participant_and_researchers_notification_results,
     ) = ae.process()
     self.assertEqual(HTTPStatus.OK,
                      storing_result["ResponseMetadata"]["HTTPStatusCode"])
     self.assertEqual(HTTPStatus.NO_CONTENT, task_completion_result)
     self.assertEqual(HTTPStatus.OK, thiscovery_team_notification_result)
     self.assertIsNone(participant_and_researchers_notification_results)
     self.clear_appointments_table()
Example #8
0
 def test_12_process_rescheduling_same_calendar_ok_link_not_generated_yet(
         self):
     self.aa1.ddb_dump(
         update_allowed=True)  # store original appointment in ddb
     event_body = (
         f"action=appointment.rescheduled"
         f"&id=399682887&calendarID=4038206"
         f"&appointmentTypeID={self.test_data['test_appointment_type_id']}")
     ae = app.AcuityEvent(acuity_event=event_body, logger=self.logger)
     (
         storing_result,
         task_completion_result,
         thiscovery_team_notification_result,
         participant_and_researchers_notification_results,
     ) = ae.process()
     self.assertEqual(HTTPStatus.OK,
                      storing_result["ResponseMetadata"]["HTTPStatusCode"])
     self.assertIsNone(task_completion_result)
     self.assertIsNone(thiscovery_team_notification_result)
     self.assertIsNone(participant_and_researchers_notification_results)
Example #9
0
 def test_10_process_cancellation_ok(self):
     self.aa1.ddb_dump()  # simulates original booking
     event_body = (
         f"action=appointment.canceled"
         f"&id={self.test_data['test_appointment_id']}&calendarID=4038206"
         f"&appointmentTypeID={self.test_data['test_appointment_type_id']}")
     ae = app.AcuityEvent(acuity_event=event_body, logger=self.logger)
     (
         storing_result,
         task_completion_result,
         thiscovery_team_notification_result,
         participant_and_researchers_notification_results,
     ) = ae.process()
     self.assertEqual(HTTPStatus.OK,
                      storing_result["ResponseMetadata"]["HTTPStatusCode"])
     self.assertIsNone(task_completion_result)
     self.assertIsNone(thiscovery_team_notification_result)
     participant_result = participant_and_researchers_notification_results.get(
         "participant")
     self.assertEqual(HTTPStatus.NO_CONTENT, participant_result)
     researchers_result = participant_and_researchers_notification_results.get(
         "researchers")
     self.assertEqual([HTTPStatus.NO_CONTENT] * 2, researchers_result)
     self.clear_appointments_table()