示例#1
0
 def test_reference_getter_without_crf_type_model(self):
     integer = 100
     crf_one = CrfOne.objects.create(subject_visit=self.subject_visit,
                                     field_int=integer)
     reference = ReferenceGetter(name="reference_app.crfone",
                                 field_name="field_int",
                                 visit_obj=crf_one.visit)
     self.assertEqual(reference.field_int, integer)
示例#2
0
 def test_reference_getter_with_bad_field_raises(self):
     integer = 100
     crf_one = CrfOne.objects.create(subject_visit=self.subject_visit,
                                     field_int=integer)
     self.assertRaises(
         ReferenceObjectDoesNotExist,
         ReferenceGetter,
         name="reference_app.crfone",
         field_name="blah",
         model_obj=crf_one,
     )
     try:
         ReferenceGetter(field_name="blah",
                         name="reference_app.crfone",
                         model_obj=crf_one)
     except ReferenceObjectDoesNotExist:
         pass
示例#3
0
 def test_reference_getter_without_using_model_obj_and_missing_visit_attr(
         self):
     integer = 100
     crf_one = CrfOne.objects.create(
         subject_visit=self.subject_visit,
         field_int=integer,
         report_datetime=self.subject_visit.report_datetime,
     )
     opts = dict(
         name="reference_app.crfone",
         field_name="field_int",
         subject_identifier=self.subject_identifier,
         report_datetime=crf_one.visit.report_datetime,
         visit_schedule_name=crf_one.visit.visit_schedule_name,
         schedule_name=crf_one.visit.schedule_name,
         visit_code=crf_one.visit.visit_code,
         timepoint=crf_one.visit.timepoint,
     )
     reference = ReferenceGetter(**opts)
     self.assertEqual(reference.field_int, integer)
示例#4
0
    def test_model_creates_and_gets_for_report_datetime(self):
        """Assert uses subject visit report_datetime and not
        CRF report_datetime for field_name='report_datetime'.
        """
        dtetime = get_utcnow()
        crf_one = CrfOne.objects.create(
            subject_visit=self.subject_visit,
            report_datetime=get_utcnow() - relativedelta(days=10),
            field_datetime=dtetime,
        )
        reference = Reference.objects.get(
            identifier=self.subject_identifier,
            model="reference_app.crfone",
            timepoint=self.subject_visit.timepoint,
            report_datetime=self.subject_visit.report_datetime,
            field_name="report_datetime",
        )
        self.assertEqual(reference.value, self.subject_visit.report_datetime)

        getter = ReferenceGetter(field_name="report_datetime",
                                 model_obj=crf_one)
        self.assertEqual(getter.value, self.subject_visit.report_datetime)
示例#5
0
 def test_reference_getter_sets_attr_even_if_none(self):
     crf_one = CrfOne.objects.create(subject_visit=self.subject_visit)
     reference = ReferenceGetter(field_name="field_int", model_obj=crf_one)
     self.assertEqual(reference.field_int, None)
示例#6
0
 def test_reference_getter_sets_attr(self):
     integer = 100
     crf_one = CrfOne.objects.create(subject_visit=self.subject_visit,
                                     field_int=integer)
     reference = ReferenceGetter(field_name="field_int", model_obj=crf_one)
     self.assertEqual(reference.field_int, integer)
示例#7
0
 def test_getter_repr(self):
     crf_one = CrfOne.objects.create(subject_visit=self.subject_visit,
                                     field_int=100)
     reference = ReferenceGetter(field_name="field_int", model_obj=crf_one)
     self.assertTrue(repr(reference))