def test_selector_return_appointment_assign(self,
                                                appointment_assign_by_id):

        # Create user
        user = user_create_superuser(first_name=fake.first_name(),
                                     last_name=fake.last_name(),
                                     password=fake.password(),
                                     email=fake.email())

        # Create specialty
        specialty_create(title=fake.bothify(text='Specialty ????-###'))

        # Create appointment
        # Add day to date
        current_date = datetime.date.today()
        add_day = timedelta(days=1)
        date = current_date + add_day

        # Set hour-> range 8:00:00 - 16:00:00
        time = datetime.time(10, 30, 00)

        appointment_assign_create(user=user.id, date=date, time=time)

        appointment_assign_id = AppointmentAssign.objects.first().id
        result = self.selector(id=appointment_assign_id)

        # Match appointment with database
        self.assertNotEqual([], len([result]))
    def test_selector_return_specialty(self, specialty_by_id_mock):

        # Create specialty
        specialty_create(title=fake.bothify(text='Specialty ????-###'))
        self.assertEqual(1, Specialty.objects.count())

        # Obtain specialty by id
        result = self.selector(id=Specialty.objects.first().id)
        self.assertNotEqual([], result)
Ejemplo n.º 3
0
    def test_specialty_update(self, specialty_update_mock):
        specialty_create(title= fake.bothify(text='Specialty ????-###'))
        
        data = OrderedDict({ 'is_active': False })
        self.service(
            specialty_id=Specialty.objects.first().id,
            data=data
        )

        self.assertFalse(Specialty.objects.first().is_active)
    def setUp(self):
        # Create a user
        self.user = user_create(first_name=fake.first_name(),
                                last_name=fake.last_name(),
                                password=fake.password(),
                                email=fake.email())

        specialty_create(title=fake.bothify(text='Specialty ????-###'))

        # Invoque service test
        self.service = appointment_remember
    def test_service_reject_true(self, appointment_delete_mock):
        # Create a specialty
        specialty_create(
            title=fake.bothify(text='Specialty ????-###'))

        # Create a appointment
        # Add day to date
        current_date = datetime.date.today()
        add_day = timedelta(days=1)
        date = current_date + add_day

        # Set hour -> range 8:00:00 - 16:00:00
        time = datetime.time(10, 30, 00)

        # Appointment return dict
        appointment = appointment_create(
            specialty=Specialty.objects.first().id,
            user=self.user.id,
            date=date,
            time=time
        )

        self.assertEqual(1, Appointment.objects.count())

        self.service(
            user_id=self.user.id,
            appointment_id=appointment.get('id')
        )

        self.assertEqual(1, Appointment.objects.count())
        self.assertTrue(Appointment.objects.first().rejected)

        # Delete a appointment with rejected=True
        # Should raise ValidationError
        with self.assertRaises(ValidationError):
            self.service(
                user_id=self.user.id,
                appointment_id=appointment.get('id')
            )
Ejemplo n.º 6
0
 def test_service_invalid_data(self, specialty_update_mock):
     specialty_create(title= fake.bothify(text='Specialty ????-###'))
     with self.assertRaises(ValidationError):
         self.service(specialty_id=Specialty.objects.first().id, data={})
Ejemplo n.º 7
0
    def test_when_has_already_been_reused(self, appointment_delete_mock):
        # Create user
        user = user_create(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            password=fake.password(),
            email=fake.email()
        )

        # Create specialty
        specialty_create(
            title=fake.bothify(text='Specialty ????-###'))

        # Create appointment
        # Add day
        current_date = datetime.date.today()
        add_day = timedelta(days=1)
        date = current_date + add_day

        # Set hour -> range 8:00:00 - 16:00:00
        time = datetime.time(10, 30, 00)

        # Appointment return dict()
        appointment_create(
            user=user.id,
            specialty=Specialty.objects.first().id,
            date=date,
            time=time
        )

        self.assertEqual(1, Appointment.objects.count())

        # Delete appoinment
        appointment_delete(
            user_id=user.id,
            appointment_id=Appointment.objects.first().id
        )

        # Create a user per reused appointment
        new_user = user_create(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            password=fake.password(),
            email=fake.email()

        )

        # Reused appointment with rejected=True
        self.service(
            user_id=new_user.id,
            appointment_id=Appointment.objects.first().id
        )

        self.assertEqual(1, Appointment.objects.count())

        # Reused appointment with rejected=False
        # Should raise ValidationError
        with self.assertRaises(ValidationError):
            self.service(
                user_id=new_user.id,
                appointment_id=Appointment.objects.first().id
            )

        self.assertEqual(1, Appointment.objects.count())