def test_approve_with_invalid_id(self):
     doctor = DoctorFactory.create()
     participant = DoctorFactory.create()
     ParticipantFactory.create(doctor_ptr=participant)
     PatientFactory.create(doctor=participant)
     study_invitation = StudyInvitationFactory.create(
         email=participant.email, doctor=doctor)
     consent = PatientConsentFactory.create()
     self.authenticate_as_doctor(doctor=participant)
     resp = self.client.post('/api/v1/study/invites/{0}/approve/'.format(
         study_invitation.pk), {
             'doctor_encryption_key': 'qwertyuiop',
             'consent_pk': consent.pk
         },
                             format='json')
     self.assertBadRequest(resp)
Esempio n. 2
0
    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)
 def test_approve_without_coordinator(self):
     coordinator = DoctorFactory.create()
     coordinator_ptr = CoordinatorFactory.create(doctor_ptr=coordinator)
     doctor = DoctorFactory.create(my_coordinator=coordinator_ptr)
     participant = DoctorFactory.create()
     ParticipantFactory.create(doctor_ptr=participant)
     patient = PatientFactory.create(doctor=participant)
     study = StudyFactory.create()
     study_invitation = StudyInvitationFactory.create(
         study=study, email=participant.email, doctor=doctor)
     self.authenticate_as_doctor(doctor=participant)
     consent = PatientConsentFactory.create(patient=patient)
     resp = self.client.post('/api/v1/study/invites/{0}/approve/'.format(
         study_invitation.pk), {
             'doctor_encryption_key': 'qwertyuiop',
             'consent_pk': consent.pk
         },
                             format='json')
     self.assertSuccessResponse(resp)
     study.refresh_from_db()
     study_invitation.refresh_from_db()
     self.assertEqual(study_invitation.status,
                      StudyInvitationStatus.ACCEPTED)
    def test_approve(self):
        coordinator = DoctorFactory.create()
        coordinator_ptr = CoordinatorFactory.create(doctor_ptr=coordinator)
        doctor = DoctorFactory.create(my_coordinator=coordinator_ptr)
        participant = DoctorFactory.create()
        ParticipantFactory.create(doctor_ptr=participant)
        patient = PatientFactory.create(doctor=participant)
        study = StudyFactory.create()
        study_invitation = StudyInvitationFactory.create(
            study=study, email=participant.email, doctor=doctor)
        self.authenticate_as_doctor(doctor=participant)
        consent = PatientConsentFactory.create(patient=patient)
        resp = self.client.post('/api/v1/study/invites/{0}/approve/'.format(
            study_invitation.pk), {
                'doctor_encryption_key': 'qwertyuiop',
                'coordinator_encryption_key': 'iqwjgipwqjeg',
                'consent_pk': consent.pk
            },
                                format='json')
        self.assertSuccessResponse(resp)
        study.refresh_from_db()
        study_invitation.refresh_from_db()
        self.assertEqual(study_invitation.status,
                         StudyInvitationStatus.ACCEPTED)

        doc_to_patient = DoctorToPatient.objects.get(doctor=doctor,
                                                     patient=patient)
        self.assertEqual(doc_to_patient.encrypted_key, 'qwertyuiop')

        coordinator_to_patient = DoctorToPatient.objects.get(
            doctor=coordinator, patient=patient)
        self.assertEqual(coordinator_to_patient.encrypted_key, 'iqwjgipwqjeg')

        study_to_patient = StudyToPatient.objects.get(study=study,
                                                      patient=patient)
        self.assertEqual(study_to_patient.patient_consent.pk, consent.pk)
        self.assertListEqual(list(study.patients.all()), [patient])
Esempio n. 5
0
    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)