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