コード例 #1
0
    def test_doctor_appointments(test_user):
        doctor_profile = DoctorProfileFactory()
        AppointmentFactory(visitor=test_user)
        doctor_appointment = AppointmentFactory(doctor=doctor_profile)

        queryset = AppointmentSelector.doctor_appointments(doctor_profile)
        assert isinstance(queryset, QuerySet)
        assert queryset.count() == 1
        assert queryset.first() == doctor_appointment
コード例 #2
0
ファイル: doctors.py プロジェクト: victoraguilarc/agendas
    def appointments(self, request, doctor_uuid, **kwargs):
        """It shows the appointments to the professionals."""

        doctor = DoctorProfileSelector.get_by_uuid(doctor_uuid)
        appointments = AppointmentSelector.doctor_appointments(doctor)
        return Response(AppointmentSerializer(appointments, many=True).data)
コード例 #3
0
 def retrieve(self, request, appointment_uuid, **kwargs):
     appointment = AppointmentSelector.get_by_uuid(appointment_uuid)
     return Response(AppointmentSerializer(appointment).data)
コード例 #4
0
    def appointments(self, request, **kwargs):
        """It shows the visitors' appointments."""

        appointments = AppointmentSelector.user_appointments(request.user)
        return Response(AppointmentSerializer(appointments, many=True).data)
コード例 #5
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data()
     context['user'] = self.request.user
     context['appointments'] = AppointmentSelector.user_appointments(self.request.user)
     return context
コード例 #6
0
 def test_user_appointments_empty(test_user):
     doctor_profile = DoctorProfileFactory()
     AppointmentFactory(doctor=doctor_profile)
     queryset = AppointmentSelector.user_appointments(test_user)
     assert isinstance(queryset, QuerySet)
     assert queryset.count() == 0
コード例 #7
0
 def test_get_by_uuid_not_found():
     with pytest.raises(NotFound) as exec_info:
         AppointmentSelector.get_by_uuid(faker.uuid4())
     assert exec_info.value.detail.code == APPOINTMENT_NOT_FOUND['code']
コード例 #8
0
 def test_get_by_uuid():
     appointment = AppointmentFactory()
     selected_appointment = AppointmentSelector.get_by_uuid(str(appointment.uuid))
     assert isinstance(selected_appointment, Appointment)
     assert selected_appointment == appointment