def setUp(self):
        self.user = User.objects.create_user(self.USERNAME,
                                             self.EMAIL,
                                             password=self.PASSWORD)
        self.patient = PatientFactory()
        self.patient.user = self.user
        self.patient.save()

        self.user_2 = User.objects.create_user("test",
                                               "*****@*****.**",
                                               password="******")
        self.patient_2 = PatientFactory()
        self.patient_2.user = self.user_2
        self.patient_2.save()
Пример #2
0
    def test_get_patient_email_confirmation_200(self):
        """
        Tests GET API for status code 200.
        Set is_confirmed field to true
        :return:
        """
        patient = PatientFactory()
        patient.is_confirmed = False
        patient.hash = uuid.uuid4().hex
        patient.save()

        url = reverse('mobile:patient-confirmation')
        url += "?token={0}".format(patient.hash)
        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            response.content.decode(),
            "Email confirmado! Clique, pelo seu celular, neste link e marque seus exames agora mesmo. Nos vemos em breve. Sara"
        )

        confirmed_patient = Patient.objects.get(pk=patient.user.id)
        self.assertTrue(confirmed_patient.is_confirmed)

        # Try to confirm again
        response = self.client.get(url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            response.content.decode(),
            "Este email já foi confirmado! Clique, pelo seu celular, neste link e marque seus exames agora mesmo. Nos vemos em breve. Sara"
        )
Пример #3
0
    def setUp(self):
        self.user = User.objects.create_user(self.USERNAME, self.EMAIL, password=self.PASSWORD)
        self.patient = PatientFactory()
        self.patient.user = self.user
        self.patient.save()

        os.environ.setdefault('RUNNING_TESTS', "1")
Пример #4
0
    def test_load_patient(self):
        patient = PatientFactory()
        url = reverse('concierge:patient-detail', kwargs={'pk': patient.pk})

        response = self.client.get(url)
        self.assertEqual(200, response.status_code)

        body = dotmap.DotMap(response.json())

        self.assertEqual('user lastname', body.full_name)
Пример #5
0
    def test_get_prescriptions_by_current_patient_404(self):
        """
        Tests GET (retrieve) API for status code 404.
        Patient exists, but doesn't have any prescription
        """
        user = User.objects.create_user('john2',
                                        '*****@*****.**',
                                        password='******')
        self.client.login(username='******', password='******')
        patient = PatientFactory()
        patient.user = user
        patient.save()

        url = reverse('mobile:patient-current/prescriptions')
        response = self.client.get(url)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Пример #6
0
    def test_get_preferred_labs_by_patient_403(self):
        """
        Tests GET (retrieve) API for status code 403.
        Trying to access data from another user.
        """
        user = User.objects.create_user('john2',
                                        '*****@*****.**',
                                        password='******')
        self.client.login(username='******', password='******')
        patient = PatientFactory()
        patient.user = user
        patient.save()

        url = reverse('mobile:patient-preferred-labs',
                      kwargs={'pk': self.current_patient.user.id})
        response = self.client.get(url)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Пример #7
0
    def test_delete_invalid_token_patient(self):
        """
        Tests DELETE method for an invalid Patient
        :return:
        """
        user = User.objects.create_user('john2',
                                        '*****@*****.**',
                                        password='******')
        self.client.login(username='******', password='******')

        patient = PatientFactory()
        patient.user = user
        patient.is_confirmed = False
        patient.save()

        url = reverse('mobile:patient-detail',
                      kwargs={'pk': self.current_patient.user.id})

        response = self.client.delete(url)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Пример #8
0
    def setUp(self):
        """
        Setting up things before tests.
        :return:
        """
        # Disabling push notification/firebase signals.
        disable_signals()

        # Getting authenticated for the next requests.
        user = User.objects.create_user('john',
                                        '*****@*****.**',
                                        password='******')
        self.client.login(username='******', password='******')

        # Creating a Laboratory (dependency for POST tests).
        self.laboratory = LaboratoryFactory()
        self.laboratory.save()

        self.current_patient = PatientFactory()
        self.current_patient.user = user
        self.current_patient.preferred_laboratories = [self.laboratory]
        self.current_patient.save()
        self.current_patient.token = uuid.uuid4().hex
Пример #9
0
 def setUp(cls):
     cls.mock_post_patcher = patch('domain.firebaser.requests.post')
     cls.mock_post = cls.mock_post_patcher.start()
     cls.patient = PatientFactory()