예제 #1
0
    def test_creates_unassigned_clinic_if_user_doesnt_exist(self):
        payload = self.clinic_registrations[0]
        raw_data = json.loads(payload)
        count = Clinic.count()
        submission = Submission(raw_data=raw_data)
        self.assertRaises(
            UserNotFound,
            ClinicRegistrationHandler(submission).handle_submission)

        # check that a clinic_submission record was NOT created
        self.assertEqual(Clinic.count(), count + 1)
예제 #2
0
    def test_raises_submission_handler_error_if_invalid_json(self):
        # check current counts
        count = Submission.count()
        clinic_count = Clinic.count()
        payload = self.clinic_registrations[1]
        self.assertRaises(SubmissionHandlerError, Submission.create_from_json,
                          payload)
        submission = Submission.newest()
        self.assertEqual(Submission.count(), count + 1)
        self.assertEqual(submission.raw_data, json.loads(payload))

        # check that a clinic record was still created
        self.assertEqual(Clinic.count(), clinic_count + 1)
예제 #3
0
    def test_create_clinic_from_submission(self):
        # create user with matching id
        DBSession.add(User())
        user = User.newest()

        payload = self.clinic_registrations[0]
        raw_data = json.loads(payload)
        raw_data[constants.USER_ID] = user.id
        submission = Submission(raw_data=raw_data)
        count = Clinic.count()
        ClinicRegistrationHandler(submission).handle_submission()

        # check that a clinic_submission record was created
        self.assertEqual(Clinic.count(), count + 1)

        clinic = Clinic.newest()
        self.assertEqual(clinic.code, '1A2B')
예제 #4
0
 def test_count_returns_count_filtered_by_criterion(self):
     self.setup_test_data()
     count = Clinic.count(Clinic.id.in_([1, 2]))
     self.assertEqual(count, 2)