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" )
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)