Example #1
0
 def test_check_ok2(self):
     name = "reference_app.crfone"
     reference_config = ReferenceModelConfig(
         fields=["field_str", "field_date", "field_datetime", "field_int"], name=name
     )
     site_reference_configs.register(reference_config=reference_config)
     site_reference_configs.check()
Example #2
0
 def test_model_raises_on_bad_field_name_checked_by_site(self):
     reference_config = ReferenceModelConfig(
         name="reference_app.crfwithbadfield",
         fields=["blah1", "blah2", "blah3", "blah4"],
     )
     site_reference_configs.register(reference_config)
     errors = site_reference_configs.check()
     self.assertIsNotNone(errors)
Example #3
0
 def test_add_fields_to_reference_config(self):
     name = "reference_app.crfone"
     fields = ["f1"]
     site_reference_configs.registry = {}
     reference_config = ReferenceModelConfig(fields=fields, name=name)
     site_reference_configs.register(reference_config)
     self.assertEqual(reference_config.field_names, ["f1"])
     site_reference_configs.add_fields_to_config(name=name, fields=["f2", "f3"])
     self.assertEqual(reference_config.field_names, ["f1", "f2", "f3"])
Example #4
0
 def test_site_reregister(self):
     name = "reference_app.crfone"
     reference_config = ReferenceModelConfig(
         name=name, fields=["field_date", "field_datetime", "field_int", "field_str"]
     )
     site_reference_configs.register(reference_config=reference_config)
     self.assertRaises(
         AlreadyRegistered,
         site_reference_configs.register,
         reference_config=reference_config,
     )
Example #5
0
 def test_model_raises_on_unknown_field_datatype(self):
     reference_config = ReferenceModelConfig(
         name="reference_app.CrfWithUnknownDatatype",
         fields=["field_decimal"])
     site_reference_configs.register(reference_config)
     self.assertRaises(
         ReferenceFieldDatatypeNotFound,
         CrfWithUnknownDatatype.objects.create,
         subject_visit=self.subject_visit,
         field_decimal=3.2,
     )
Example #6
0
 def test_get_config(self):
     site_reference_configs.registry = {}
     name = "reference_app.crfone"
     fields = ["f1"]
     reference_config = ReferenceModelConfig(fields=fields, name=name)
     site_reference_configs.register(reference_config)
     self.assertEqual(
         reference_config,
         site_reference_configs.get_config(name="reference_app.crfone"),
     )
     self.assertRaises(
         SiteReferenceConfigError, site_reference_configs.get_config, name=None
     )
Example #7
0
    def reset_site_reference_configs(self):
        site_reference_configs.registry = {}
        site_reference_configs.loaded = False
        site_reference_configs.registered_from_visit_schedules = False

        subjectvisit_reference = ReferenceModelConfig(
            name="reference_app.subjectvisit",
            fields=["report_datetime", "visit_code"])

        self.testmodel_reference = ReferenceModelConfig(
            name="reference_app.testmodel",
            fields=["field_str", "report_datetime"])
        self.crfone_reference = ReferenceModelConfig(
            name="reference_app.crfone",
            fields=[
                "field_str",
                "field_date",
                "field_datetime",
                "field_int",
                "report_datetime",
            ],
        )
        site_reference_configs.register(subjectvisit_reference)
        site_reference_configs.register(self.testmodel_reference)
        site_reference_configs.register(self.crfone_reference)
Example #8
0
    def setUp(self):
        site_reference_configs.registry = {}
        site_reference_configs.loaded = False

        ref_config = ReferenceModelConfig(
            name="reference_app.subjectvisit",
            fields=["report_datetime", "visit_code", "visit_code_sequence"],
        )
        site_reference_configs.register(ref_config)

        self.testmodel_reference = ReferenceModelConfig(
            name="reference_app.testmodel",
            fields=["field_str", "report_datetime"])
        site_reference_configs.register(self.testmodel_reference)

        self.crfone_reference = ReferenceModelConfig(
            name="reference_app.crfone",
            fields=[
                "field_str",
                "field_date",
                "field_datetime",
                "field_int",
                "report_datetime",
            ],
        )
        site_reference_configs.register(self.crfone_reference)

        self.subject_identifier = "12345678"

        SubjectConsent.objects.create(
            subject_identifier=self.subject_identifier,
            consent_datetime=get_utcnow() - relativedelta(days=10),
            identity="123456789",
            confirm_identity="123456789",
            site=Site.objects.get_current(),
        )

        on_schedule = OnSchedule.objects.create(
            subject_identifier=self.subject_identifier,
            onschedule_datetime=get_utcnow() - relativedelta(days=10),
        )
        on_schedule.put_on_schedule()
        appointment = Appointment.objects.get(timepoint=0.0)
        self.subject_visit = SubjectVisit.objects.create(
            subject_identifier=self.subject_identifier,
            report_datetime=get_utcnow() - relativedelta(days=10),
            reason=SCHEDULED,
            appointment=appointment,
            visit_schedule_name="visit_schedule",
            schedule_name="schedule",
            visit_code="1000",
            visit_code_sequence=0,
            site=Site.objects.get_current(),
        )
Example #9
0
 def test_site_register(self):
     name = "reference_app.crfone"
     fields = ["field_date", "field_datetime", "field_int", "field_str"]
     reference_config = ReferenceModelConfig(fields=fields, name=name)
     site_reference_configs.register(reference_config=reference_config)
     self.assertEqual(fields, site_reference_configs.get_fields(name=name))
Example #10
0
 def test_raises_on_missing_model_mixin(self):
     reference_config = ReferenceModelConfig(
         name="reference_app.TestModelBad", fields=["report_datetime"])
     site_reference_configs.register(reference_config)
     errors = site_reference_configs.check()
     self.assertIsNotNone(errors)