예제 #1
0
    def test_get_item_returns_clinic_if_id_exists(self):
        self.setup_test_data()
        clinic = Clinic.newest()

        request = testing.DummyRequest()
        clinic = ClinicFactory(request).__getitem__(clinic.id)
        self.assertIsInstance(clinic, Clinic)
예제 #2
0
 def test_get_item_returns_reporting_period(self):
     self.setup_test_data()
     period = ReportingPeriod(
         title="2013/2014",
         start_date=datetime.datetime(2013, 3, 13),
         end_date=datetime.datetime(2014, 3, 13))
     DBSession.add(period)
     DBSession.flush()
     period = ReportingPeriod.newest()
     clinic = Clinic.newest()
     selected_period = clinic.__getitem__(period.id)
     self.assertIsInstance(selected_period, ReportingPeriod)
     self.assertEqual(selected_period, period)
예제 #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_raise_key_error_when_invalid_period_id(self):
     self.setup_test_data()
     clinic = Clinic.newest()
     self.assertRaises(KeyError, clinic.__getitem__, "abc")