def setUp(self): super(StudyViewSetTest, self).setUp() self.coordinator = CoordinatorFactory.create(doctor_ptr=self.doctor) self.other_doctor = DoctorFactory(password='******') self.patient = PatientFactory.create() self.consent_doc = ConsentDocFactory.create()
def test_get_by_email_for_exists_patient(self): self.authenticate_as_doctor() study = StudyFactory.create() patient = PatientFactory.create(doctor=self.doctor) StudyInvitationFactory.create(email='*****@*****.**', doctor=self.doctor, study=study, patient=patient) resp = self.client.get( '/api/v1/doctor/get_by_email/[email protected]') self.assertBadRequest(resp)
def test_validate_study_consent(self): study = StudyFactory.create() patient = PatientFactory.create() expired = timezone.now() - timedelta(days=1) consent = PatientConsentFactory.create(patient=patient, date_expired=expired) StudyToPatient.objects.create(study=study, patient=patient, patient_consent=consent) validate_study_consent_for_patient(study, patient)
def setUp(self): super(MolesTestCase, self).setUp() self.first_patient = PatientFactory.create(doctor=self.doctor) self.first_patient_consent = PatientConsentFactory( patient=self.first_patient) self.another_patient = PatientFactory() self.anatomical_site = AnatomicalSiteFactory.create() self.first_patient_asite = PatientAnatomicalSiteFactory.create( patient=self.first_patient, anatomical_site=self.anatomical_site) self.another_patient_asite = PatientAnatomicalSiteFactory.create( patient=self.another_patient, anatomical_site=self.anatomical_site) self.first_patient_mole = MoleFactory.create( patient=self.first_patient, anatomical_site=self.anatomical_site) self.another_patient_mole = MoleFactory.create( patient=self.another_patient, anatomical_site=self.anatomical_site)
def test_validate_study_consent_with_error(self): study = StudyFactory.create() patient = PatientFactory.create() expired = timezone.now() - timedelta(days=1) consent = PatientConsentFactory.create(patient=patient, date_expired=expired) consent.date_expired = expired consent.save() StudyToPatient.objects.create(study=study, patient=patient, patient_consent=consent) with self.assertRaises(serializers.ValidationError): validate_study_consent_for_patient(study, patient)
def test_register_as_doctor_with_patient_email(self): study = StudyFactory.create() patient = PatientFactory.create(doctor=self.doctor) StudyInvitationFactory.create(email='*****@*****.**', doctor=self.doctor, study=study, patient=patient) data = { 'first_name': Faker('first_name').generate({}), 'last_name': Faker('last_name').generate({}), 'email': '*****@*****.**', 'password': Faker('password').generate({}), 'site': self.site.id, } resp = self.client.post('/api/v1/auth/register/', data) self.assertBadRequest(resp)
def setUp(self): self.doctor = DoctorFactory.create() self.patient = PatientFactory.create() self.study = StudyFactory.create( author=CoordinatorFactory.create() ) self.study.doctors.add(self.doctor) self.study.save() DoctorToPatient.objects.create( doctor=self.doctor, patient=self.patient) consent = PatientConsentFactory.create( patient=self.patient) self.study_to_patient = StudyToPatient.objects.create( study=self.study, patient=self.patient, patient_consent=consent)