Exemplo n.º 1
0
    def test_daily_make_confirmed_applications_completed_for_ended_shifts(
            self, mock_process_completing):
        not_ended_shift = ShiftFactory.create()
        confirmed_application_for_not_ended_shift = ApplicationFactory.create(
            shift=not_ended_shift, state=ApplicationStateEnum.CONFIRMED)

        ended_shift = ShiftFactory.create(
            date_start=timezone.now() - timedelta(days=3),
            date_end=timezone.now() - timedelta(days=2))
        new_application = ApplicationFactory.create(
            shift=ended_shift, state=ApplicationStateEnum.NEW)
        confirmed_application = ApplicationFactory.create(
            shift=ended_shift, state=ApplicationStateEnum.CONFIRMED)
        completed_application = ApplicationFactory.create(
            shift=ended_shift, state=ApplicationStateEnum.COMPLETED)

        daily_make_confirmed_applications_completed_for_ended_shifts()

        confirmed_application_for_not_ended_shift.refresh_from_db()
        self.assertEqual(confirmed_application_for_not_ended_shift.state,
                         ApplicationStateEnum.CONFIRMED)

        new_application.refresh_from_db()
        self.assertEqual(new_application.state, ApplicationStateEnum.NEW)

        completed_application.refresh_from_db()
        self.assertEqual(completed_application.state,
                         ApplicationStateEnum.COMPLETED)

        confirmed_application.refresh_from_db()
        self.assertEqual(confirmed_application.state,
                         ApplicationStateEnum.COMPLETED)

        mock_process_completing.assert_called_once_with(
            confirmed_application, ended_shift.owner.user_ptr, '')
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def test_apply_for_unsuitable_shift_by_approved_resident_failed(self):
        self.authenticate_as_resident(self.approved_resident)

        started_shift = ShiftFactory.create()

        data = self.get_apply_data(shift=started_shift.pk)
        resp = self.client.post('/api/shifts/application/apply/',
                                data,
                                format='json')
        self.assertBadRequest(resp)
        self.assertEqual(
            resp.data['shift'],
            ['You can not create an application for not suitable shift'])
Exemplo n.º 4
0
    def test_apply_for_started_shift_by_approved_resident_failed(self):
        self.authenticate_as_resident(self.approved_resident)

        started_shift = ShiftFactory.create(speciality=self.first_speciality,
                                            date_start=timezone.now())

        data = self.get_apply_data(shift=started_shift.pk)
        resp = self.client.post('/api/shifts/application/apply/',
                                data,
                                format='json')
        self.assertBadRequest(resp)
        self.assertEqual(
            resp.data['shift'],
            ['You can not create an application for a started shift'])
Exemplo n.º 5
0
 def setUp(self):
     self.request = ExtendedRequestFactory()
     self.scheduler = SchedulerFactory.create()
     self.resident = ResidentFactory.create()
     self.shift = ShiftFactory.create(owner=self.scheduler)
     self.application = ApplicationFactory.create(shift=self.shift)
     self.message = MessageFactory.create(owner=self.resident,
                                          application=self.application,
                                          text='test text')
     self.message2 = MessageFactory.create(owner=self.resident,
                                           application=self.application,
                                           text='see attachment',
                                           attachment=SimpleUploadedFile(
                                               'text.txt',
                                               b'Some text in file'))
Exemplo n.º 6
0
    def test_invite_for_started_shift_by_scheduler_failed(self):
        self.authenticate_as_scheduler()

        started_shift = ShiftFactory.create(owner=self.scheduler,
                                            speciality=self.first_speciality,
                                            date_start=timezone.now())

        data = self.get_invite_data(shift=started_shift.pk)
        resp = self.client.post('/api/shifts/application/invite/',
                                data,
                                format='json')
        self.assertBadRequest(resp)
        self.assertEqual(
            resp.data['shift'],
            ['You can not create an application for a started shift'])
Exemplo n.º 7
0
    def setUp(self):
        super(ShiftTest, self).setUp()

        self.shift = ShiftFactory.create()
Exemplo n.º 8
0
 def setUp(self):
     self.scheduler = SchedulerFactory.create()
     self.resident = ResidentFactory.create()
     self.shift = ShiftFactory.create(owner=self.scheduler)
     self.application = ApplicationFactory.create(shift=self.shift,
                                                  owner=self.resident)
Exemplo n.º 9
0
 def setUp(self):
     self.request = ExtendedRequestFactory()
     self.scheduler = SchedulerFactory.create()
     self.resident = ResidentFactory.create()
     self.shift = ShiftFactory.create(owner=self.scheduler)
Exemplo n.º 10
0
    def setUp(self):
        super(ApplicationTest, self).setUp()

        self.resident = ResidentFactory.create()
        self.scheduler = SchedulerFactory.create()
        self.shift = ShiftFactory.create(owner=self.scheduler)