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)
示例#2
0
 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 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)
示例#4
0
 def setUpClass(cls):
     super().setUpClass()
     site_list_data.autodiscover()
     cls.selenium = WebDriver()
     cls.selenium.implicitly_wait(10)
示例#5
0
 def test_(self):
     # TODO: Validate
     site_list_data.initialize()
     site_list_data.autodiscover()
示例#6
0
 def test_(self):
     site_list_data.autodiscover()
示例#7
0
 def setUpClass(cls):
     site_list_data.autodiscover()
     super().setUpClass()
示例#8
0
 def setUpClass(cls):
     site_list_data.autodiscover()
     import_holidays()
     super().setUpClass()
示例#9
0
 def handle(self, *args, **options):
     try:
         site_list_data.autodiscover()
     except SiteListDataError as e:
         raise CommandError(e)