def populate_list(self, site_names=None, per_site=None): make_test_list( site_names=site_names or self.site_names, per_site=per_site, full_path=settings.EDC_RANDOMIZATION_LIST_FILE, ) RandomizationListImporter(name="ambition", overwrite=True)
def setUpClass(cls): super().setUpClass() if cls.import_randomization_list: RandomizationListImporter(verbose=False) import_holidays(test=True) site_list_data.autodiscover() GroupPermissionsUpdater(codenames_by_group=get_codenames_by_group(), verbose=True)
def setUpTestData(cls): import_holidays(test=True) if cls.import_randomization_list: RandomizationListImporter( verbose=False, name="default", sid_count_for_tests=cls.sid_count_for_tests, )
def test_invalid_sid(self): # change to a different starting SID RandomizationListImporter() obj = RandomizationList.objects.all().order_by("sid").first() obj.sid = 100 obj.save() message = RandomizationListVerifier().message self.assertIn("Randomization list is invalid", message or "")
def test_invalid_sid(self): # change to a different starting SID RandomizationListImporter(name="ambition") obj = RandomizationList.objects.all().order_by("sid").first() obj.sid = 100 obj.save() with self.assertRaises(RandomizationListError) as cm: RandomizationListVerifier(randomizer_name="ambition") self.assertIn("Randomization list has invalid SIDs", str(cm.exception))
def setUpClass(cls): super().setUpClass() import_holidays(test=True) add_or_update_django_sites(sites=get_sites_by_country("tanzania")) site_list_data.autodiscover() GroupPermissionsUpdater(codenames_by_group=get_codenames_by_group(), verbose=True) if cls.import_randomization_list: RandomizationListImporter(verbose=False, name="default")
def populate_list(self, site_names=None, per_site=None): make_test_list( site_names=site_names or self.site_names, per_site=per_site, full_path=os.path.join( settings.EDC_RANDOMIZATION_LIST_PATH, site_randomizers.get("ambition").filename, ), ) RandomizationListImporter(name="ambition", overwrite=True)
def test_invalid_count(self): site = Site.objects.get_current() # change number of SIDs in DB RandomizationListImporter() RandomizationList.objects.create( sid=100, drug_assignment="active", site_name=site.name ) self.assertEqual(RandomizationList.objects.all().count(), 41) message = RandomizationListVerifier().message self.assertIn("Randomization list count is off", message)
def setUpClass(cls): super().setUpClass() site_randomizers._registry = {} site_randomizers.register(Randomizer) add_or_update_django_sites( apps=django_apps, sites=ambition_sites, fqdn=fqdn, verbose=False ) if cls.import_randomization_list: RandomizationListImporter(name="ambition", verbose=False) import_holidays(test=True)
def test_invalid_count(self): Randomizer.model_cls().objects.all().delete() site = Site.objects.get_current() RandomizationListImporter(name="ambition") # change number of SIDs in DB self.assertEqual(Randomizer.model_cls().objects.all().count(), 50) Randomizer.model_cls().objects.create(sid=100, assignment="single_dose", site_name=site.name) self.assertEqual(Randomizer.model_cls().objects.all().count(), 51) self.assertRaises( RandomizationListError, RandomizationListVerifier, randomizer_name="ambition", ) with self.assertRaises(RandomizationListError) as cm: RandomizationListVerifier(randomizer_name="ambition") self.assertIn("Randomization list count is off. Expected 51. Got 50", str(cm.exception))
def test_to_subject_dashboard(self): add_or_update_django_sites(apps=django_apps, sites=ambition_sites, fqdn=fqdn) RandomizationListImporter() GroupPermissionsUpdater() import_holidays() site_list_data.autodiscover() self.login(superuser=False, groups=[EVERYONE, CLINIC, PII]) subject_screening = baker.make_recipe( "ambition_screening.subjectscreening") home_page = self.app.get(reverse("home_url"), user=self.user, status=200) screening_listboard_page = home_page.click(description="Screening", index=1) add_subjectconsent_page = screening_listboard_page.click( description="Consent", index=1) # submit blank form response = add_subjectconsent_page.form.submit() self.assertIn("Please correct the errors below", response) subject_consent = baker.make_recipe( "ambition_subject.subjectconsent", screening_identifier=subject_screening.screening_identifier, dob=(get_utcnow() - relativedelta(years=subject_screening.age_in_years)).date(), first_name="Melissa", last_name="Rodriguez", initials="MR", consent_datetime=get_utcnow(), ) home_page = self.app.get(reverse("home_url"), user=self.user, status=200) screening_listboard_page = home_page.click(description="Screening", index=1) self.assertIn("Dashboard", screening_listboard_page) self.assertIn( f"subjectscreening_change_{subject_screening.screening_identifier}", screening_listboard_page, ) home_page = self.app.get(reverse("home_url"), user=self.user, status=200) subject_listboard_page = home_page.click(description="Subjects", index=1) self.assertIn(subject_consent.subject_identifier, subject_listboard_page) href = reverse( "ambition_dashboard:subject_dashboard_url", kwargs={"subject_identifier": subject_consent.subject_identifier}, ) subject_dashboard_page = subject_listboard_page.click(href=href) self.assertEqual(subject_dashboard_page.status_code, 200) # on subject_dashboard # assert all appointment are showing subject_identifier = subject_consent.subject_identifier appointments = Appointment.objects.filter( subject_identifier=subject_identifier).order_by("appt_datetime") for appointment in appointments: self.assertIn(appointment.visit_code, subject_dashboard_page) # start appointment 1000 page = subject_dashboard_page.click(linkid="start_btn_1000") page.form["appt_status"] = IN_PROGRESS_APPT page.form["appt_reason"] = SCHEDULED_APPT subject_dashboard_page = page.form.submit() self.assertEqual(subject_dashboard_page.status_code, 302) self.assertEqual( subject_dashboard_page.url, f"/subject/subject_dashboard/{subject_identifier}/", ) subject_dashboard_page = self.app.get(subject_dashboard_page.url, user=self.user, status=200) # start visit 1000 self.assertIn(" Start ", subject_dashboard_page) subject_visit_page = subject_dashboard_page.click( linkid=(f"start_btn_{appointments[0].visit_code}_" f"{appointments[0].visit_code_sequence}")) subject_visit_page.form["info_source"] = "patient" subject_dashboard_page = subject_visit_page.form.submit() url = (f"/subject/subject_dashboard/{subject_identifier}/" f"{str(appointments[0].pk)}/") self.assertEqual(subject_dashboard_page.status_code, 302) self.assertEqual(subject_dashboard_page.url, url) subject_dashboard_page = self.app.get( reverse( "ambition_dashboard:subject_dashboard_url", kwargs=dict( subject_identifier=subject_identifier, appointment=str(appointments[0].id), ), ), user=self.user, status=200, ) self.assertIn("CRFs", subject_dashboard_page) self.assertIn("Requisitions", subject_dashboard_page)
def populate_list(self, site_names=None, per_site=None): path = make_test_list( site_names=site_names or self.site_names, per_site=per_site ) RandomizationListImporter(path=path, overwrite=True)