def test_upload_file(self): doctor_username = '******' patient_username = '******' password = '******' hospital = Hospital.create_default() Group.objects.create(name='Patient') Group.objects.create(name='Doctor') create_default_account(doctor_username, password, Doctor, hospital) create_default_account(patient_username, password, Patient, hospital) doctor = User.objects.get(username=doctor_username).doctor patient = User.objects.get(username=patient_username).patient diagnosis = Diagnosis.objects.create(patient=patient) test = Test.objects.create(doctor=doctor, diagnosis=diagnosis, description="", results=SimpleUploadedFile( 'file.txt', b'test file')) response = self.client.post( reverse('medical:upload_test_result', args=[test.id])) self.assertEqual(response.status_code, 302, 'Expected to upload test result.')
def setUpTestData(cls): Hospital.create_default()
def setUpTestData(cls): Group.objects.create(name='Patient') Hospital.create_default()