Пример #1
0
 def test_last_update_time_set(self):
     """We don't see a LastUpdateTime for naiive elements"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     obj.set_update_time()
     tested = obj_to_doc(obj)
     self.assertEqual("ItemData", tested.tag)
     self.assertIsNotNone(tested.get('mdsol:LastUpdateTime'))
Пример #2
0
 def test_last_update_time_set(self):
     """We don't see a LastUpdateTime for naiive elements"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     obj.set_update_time()
     tested = obj_to_doc(obj)
     self.assertEqual("ItemData", tested.tag)
     self.assertIsNotNone(tested.get('mdsol:LastUpdateTime'))
Пример #3
0
 def test_add_milestone(self):
     """We add a single milestone"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     obj.add_milestone("Informed Consent")
     tested = obj_to_doc(obj)
     self.assertEqual('Annotation', list(tested)[0].tag)
     annotation = list(tested)[0]
     self.assertEqual('Informed Consent', list(list(annotation)[0])[0].text)
Пример #4
0
 def test_add_last_update_time(self):
     """We add a LastUpdateTime"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     now = datetime.datetime.utcnow()
     obj.last_update_time = now
     tested = obj_to_doc(obj)
     self.assertEqual("ItemData", tested.tag)
     self.assertEqual(now.isoformat(), tested.get('mdsol:LastUpdateTime'))
Пример #5
0
 def test_modm_bool_attribute(self):
     """A boolean gets mapped to Yes or No"""
     data = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     data.add_attribute("IsSDVRequired", True)
     data.add_attribute("IsSDVComplete", False)
     tested = obj_to_doc(data)
     self.assertEqual(tested.get("mdsol:IsSDVRequired"), "Yes")
     self.assertEqual(tested.get("mdsol:IsSDVComplete"), "No")
Пример #6
0
 def test_gate_modm_attributes(self):
     """We add a mdsol:Nonsense"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     now = datetime.datetime.utcnow()
     obj.last_update_time = now
     with self.assertRaises(ValueError) as exc:
         obj.add_attribute("Nonsense", "85D4F9F0-9F49-42F3-A8E7-413DE85CC55E")
     self.assertEqual("Can't add Nonsense to ItemData", str(exc.exception))
Пример #7
0
 def test_add_milestone(self):
     """We add a single milestone"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     obj.add_milestone("Informed Consent")
     tested = obj_to_doc(obj)
     self.assertEqual('Annotation', list(tested)[0].tag)
     annotation = list(tested)[0]
     self.assertEqual('Informed Consent', list(list(annotation)[0])[0].text)
Пример #8
0
 def test_add_last_update_time(self):
     """We add a LastUpdateTime"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     now = datetime.datetime.utcnow()
     obj.last_update_time = now
     tested = obj_to_doc(obj)
     self.assertEqual("ItemData", tested.tag)
     self.assertEqual(now.isoformat(), tested.get('mdsol:LastUpdateTime'))
Пример #9
0
 def test_gate_modm_attributes(self):
     """We add a mdsol:Nonsense"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     now = datetime.datetime.utcnow()
     obj.last_update_time = now
     with self.assertRaises(ValueError) as exc:
         obj.add_attribute("Nonsense",
                           "85D4F9F0-9F49-42F3-A8E7-413DE85CC55E")
     self.assertEqual("Can't add Nonsense to ItemData", str(exc.exception))
Пример #10
0
 def test_add_item_uuid(self):
     """We add a mdsol:ItemUUID"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     now = datetime.datetime.utcnow()
     obj.last_update_time = now
     obj.add_attribute("ItemUUID", "85D4F9F0-9F49-42F3-A8E7-413DE85CC55E")
     tested = obj_to_doc(obj)
     self.assertEqual("ItemData", tested.tag)
     self.assertEqual(now.isoformat(), tested.get('mdsol:LastUpdateTime'))
     self.assertEqual("85D4F9F0-9F49-42F3-A8E7-413DE85CC55E", tested.get('mdsol:ItemUUID'))
Пример #11
0
 def test_add_item_uuid(self):
     """We add a mdsol:ItemUUID"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     now = datetime.datetime.utcnow()
     obj.last_update_time = now
     obj.add_attribute("ItemUUID", "85D4F9F0-9F49-42F3-A8E7-413DE85CC55E")
     tested = obj_to_doc(obj)
     self.assertEqual("ItemData", tested.tag)
     self.assertEqual(now.isoformat(), tested.get('mdsol:LastUpdateTime'))
     self.assertEqual("85D4F9F0-9F49-42F3-A8E7-413DE85CC55E",
                      tested.get('mdsol:ItemUUID'))
Пример #12
0
 def test_modm_attributes(self):
     """Each modm attribute is settable"""
     for attribute in ["ItemUUID",
                       "SDRCompleteDate", "SDVCompleteDate", "LockCompleteDate",
                       "IsSDVRequired", "IsSDVComplete"]:
         data = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
         if "UUID" in attribute:
             data.add_attribute(attribute, uuid.uuid4())
         elif "Date" in attribute:
             data.add_attribute(attribute, fake.date_time_this_year(before_now=True,
                                                                    after_now=False,
                                                                    tzinfo=None))
         elif attribute.startswith('Is'):
             data.add_attribute(attribute, random.choice(YesNoRave))
         else:
             data.add_attribute(attribute, "Blargle")
         tested = obj_to_doc(data)
         self.assertIsNotNone(tested.get("mdsol:{}".format(attribute)))
Пример #13
0
 def test_invalid_modm_attributes(self):
     """Each invalid modm attribute raises an exception"""
     for attribute in ["StudyUUID"]:
         obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
         with self.assertRaises(ValueError) as exc:
             if "UUID" in attribute:
                 obj.add_attribute(attribute, uuid.uuid4())
             elif "Date" in attribute:
                 obj.add_attribute(attribute, fake.date_time_this_year(before_now=True,
                                                                       after_now=False,
                                                                       tzinfo=None))
             else:
                 obj.add_attribute(attribute, "Blargle")
         self.assertEqual("Can't add {} to ItemData".format(attribute), str(exc.exception))
Пример #14
0
 def test_gate_modm_milestones_global(self):
     """We add a mdsol:Nonsense"""
     igp = ItemGroupData("LOG_LINE")
     brth = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     brth.add_milestone("Birth Date")
     igp << brth
     ifc = ItemData(itemoid="DSSTDAT_IFC", value="12 DEC 1975")
     ifc.add_milestone("Informed Consent")
     igp << ifc
     tested = obj_to_doc(igp)
     self.assertEqual('ItemGroupData', tested.tag)
     self.assertEqual('ItemData', list(tested)[0].tag)
     idata_zero = list(tested)[0]
     self.assertEqual('Annotation', list(idata_zero)[0].tag)
     anno = list(idata_zero)[0]
     self.assertEqual(1, len(list(anno)))
Пример #15
0
 def test_add_last_update_time_with_invalid_time(self):
     """We add a LastUpdateTime with a nonsense value"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     now = "2017-04-21"
     with self.assertRaises(ValueError) as exc:
         obj.last_update_time = now
Пример #16
0
 def test_add_last_update_time_with_invalid_time(self):
     """We add a LastUpdateTime with a nonsense value"""
     obj = ItemData(itemoid="BRTHDAT", value="12 DEC 1975")
     now = "2017-04-21"
     with self.assertRaises(ValueError) as exc:
         obj.last_update_time = now