Ejemplo n.º 1
0
    def setUp(self):
        super(ShiftsTestCaseMixin, self).setUp()

        self.first_speciality = SpecialityFactory.create()
        self.second_speciality = SpecialityFactory.create()
        self.first_shift = ShiftFactory.create(
            residency_years_required=0, speciality=self.first_speciality)
        self.second_shift = ShiftFactory.create(
            residency_years_required=5, speciality=self.second_speciality)

        self.approved_resident = ResidentFactory.create(
            state=ResidentStateEnum.APPROVED,
            residency_years=5,
        )
        self.approved_resident.specialities.add(self.first_speciality,
                                                self.second_speciality)
Ejemplo n.º 2
0
 def test_update_without_state_license_without_states_success(self):
     self.authenticate_as_resident()
     data = {
         'specialities': '[{0}]'.format(SpecialityFactory.create().pk),
         'residency_years': 2017,
         'state_license': False,
         'state_license_states': '[]',
     }
     resp = self.client.patch('/api/accounts/resident/{0}/'.format(
         self.resident.pk), data, format='json')
     self.assertSuccessResponse(resp)
Ejemplo n.º 3
0
 def test_update_with_state_license_with_states_success(self):
     self.authenticate_as_resident()
     data = {
         'specialities': '[{0}]'.format(SpecialityFactory.create().pk),
         'residency_years': 2017,
         'state_license': True,
         'state_license_states': '["AL", "AK"]',
     }
     resp = self.client.patch('/api/accounts/resident/{0}/'.format(
         self.resident.pk), data, format='json')
     self.assertSuccessResponse(resp)
     self.resident.refresh_from_db()
     self.assertEqual(self.resident.state_license_states, ['AL', 'AK'])
Ejemplo n.º 4
0
 def test_update_with_state_license_without_states_failed(self):
     self.authenticate_as_resident()
     data = {
         'specialities': '[{0}]'.format(SpecialityFactory.create().pk),
         'residency_years': 2017,
         'state_license': True,
         'state_license_states': '[]',
     }
     resp = self.client.patch('/api/accounts/resident/{0}/'.format(
         self.resident.pk), data, format='json')
     self.assertBadRequest(resp)
     self.assertEqual(
         resp.data['state_license_states'],
         ['You must choose at least one state where you have state licence'])
Ejemplo n.º 5
0
    def test_update_myself_by_resident_success(self):
        self.authenticate_as_resident()
        speciality_pk = SpecialityFactory.create().pk
        data = {
            'specialities': '[{0}]'.format(speciality_pk),
            'residency_years': 2017,
        }
        resp = self.client.patch('/api/accounts/resident/{0}/'.format(
            self.resident.pk), data, format='json')
        self.assertSuccessResponse(resp)

        self.resident.refresh_from_db()
        self.assertSetEqual(
            set(self.resident.specialities.values_list('pk', flat=True)),
            {speciality_pk})
        self.assertEqual(self.resident.residency_years, data['residency_years'])
Ejemplo n.º 6
0
 def setUp(self):
     self.speciality = SpecialityFactory.create()