def test_add_description(self):
     tt1 = DEFINE.TranslatedText(_content="Age at Screening Date (Screening Date - Birth date)", lang="en")
     tt2 = DEFINE.TranslatedText(_content="For the complete algorithm see the referenced external document.", lang="fr")
     self.methoddef.Description = DEFINE.Description()
     self.methoddef.Description.TranslatedText = [tt1, tt2]
     self.assertEqual(len(self.methoddef.Description.TranslatedText), 2)
     self.assertEqual(self.methoddef.Description.TranslatedText[1]._content,
                      'For the complete algorithm see the referenced external document.')
Exemple #2
0
 def test_to_xml_description(self):
     tt1 = DEFINE.TranslatedText(_content="this is the first test description", lang="en")
     tt2 = DEFINE.TranslatedText(_content="this is the second test description", lang="en")
     desc = DEFINE.Description()
     desc.TranslatedText = [tt1, tt2]
     desc_xml = desc.to_xml()
     tts = desc_xml.findall("TranslatedText")
     self.assertEqual(tts[0].text, "this is the first test description")
Exemple #3
0
 def test_to_dict_description(self):
     tt1 = DEFINE.TranslatedText(_content="this is the first test description", lang="en")
     tt2 = DEFINE.TranslatedText(_content="this is the second test description", lang="en")
     desc = DEFINE.Description()
     desc.TranslatedText = [tt1, tt2]
     desc_dict = desc.to_dict()
     print(desc_dict)
     self.assertDictEqual(desc_dict["TranslatedText"][1],
                          {'_content': 'this is the second test description', 'lang': 'en'})
Exemple #4
0
 def test_add_description(self):
     tt1 = DEFINE.TranslatedText(
         _content="this is the first test description", lang="en")
     tt2 = DEFINE.TranslatedText(
         _content="this is the second test description", lang="en")
     self.igd.Description = DEFINE.Description()
     self.igd.Description.TranslatedText = [tt1, tt2]
     self.assertEqual(len(self.igd.Description.TranslatedText), 2)
     self.assertEqual(self.igd.Description.TranslatedText[1]._content,
                      'this is the second test description')
Exemple #5
0
 def test_add_value_list_ref(self):
     vlr = DEFINE.ValueListRef(ValueListOID="VL.DA.DAORRES")
     attrs = {"OID": "IT.DA.DAORRES", "Name": "DAORRES", "DataType": "text", "Length": "2", "SASFieldName": "DAORRES"}
     itd = DEFINE.ItemDef(**attrs)
     tt1 = DEFINE.TranslatedText(_content="Assessment Result in Original Units", lang="en")
     desc = DEFINE.Description()
     desc.TranslatedText.append(tt1)
     itd.Description = desc
     itd.ValueListRef = vlr
     self.assertEqual(itd.ValueListRef.ValueListOID, "VL.DA.DAORRES")
     self.assertEqual(itd.OID, "IT.DA.DAORRES")
 def test_to_dict(self):
     attrs = self.set_attributes()
     method = DEFINE.MethodDef(**attrs)
     desc = DEFINE.Description()
     tt1 = DEFINE.TranslatedText(_content="Age at Screening Date (Screening Date - Birth date)", lang="en")
     desc.TranslatedText = [tt1]
     method.Description = desc
     fex = DEFINE.FormalExpression(Context="Python 3.7", _content="print('hello world')")
     method.FormalExpression = [fex]
     method_dict = method.to_dict()
     self.assertEqual(method_dict["OID"], "ODM.MT.AGE")
     self.assertDictEqual(method_dict, self.expected_dict())
Exemple #7
0
 def test_itemgroupdef_iterator(self):
     """ test the ability to reference a specific or slice of ItemRefs """
     attrs = self.set_itemgroupdef_attributes()
     igd = DEFINE.ItemGroupDef(**attrs)
     tt = DEFINE.TranslatedText(_content="Vital Signs", lang="en")
     igd.Description = DEFINE.Description()
     igd.Description.TranslatedText = [tt]
     item_refs = self.set_itemrefs()
     igd.ItemRef = item_refs
     parser = ODM_PARSER.ODMParser(self.test_file, self.nsr)
     parser.parse()
     parser.MetaDataVersion()
     irs = [ir.ItemOID for ir in igd]
     self.assertEqual(len(irs), 10)
Exemple #8
0
 def test_itemgroupdef_slice(self):
     """ test the ability to reference a specific or slice of ItemRefs """
     attrs = self.set_itemgroupdef_attributes()
     igd = DEFINE.ItemGroupDef(**attrs)
     tt = DEFINE.TranslatedText(_content="Vital Signs", lang="en")
     igd.Description = DEFINE.Description()
     igd.Description.TranslatedText = [tt]
     item_refs = self.set_itemrefs()
     igd.ItemRef = item_refs
     parser = ODM_PARSER.ODMParser(self.test_file, self.nsr)
     parser.parse()
     parser.MetaDataVersion()
     self.assertEqual(len(igd), 10)
     self.assertEqual(igd.ItemRef[0].ItemOID, "IT.STUDYID")
     slice_itr = igd.ItemRef[1:5]
     self.assertEqual(slice_itr[1].ItemOID, "IT.TA.ARMCD")
Exemple #9
0
 def test_itemgroupdef_round_trip(self):
     """ system test to create and serialize an ItemGroupDef object """
     attrs = self.set_itemgroupdef_attributes()
     igd = DEFINE.ItemGroupDef(**attrs)
     tt = DEFINE.TranslatedText(_content="Vital Signs", lang="en")
     igd.Description = DEFINE.Description()
     igd.Description.TranslatedText = [tt]
     item_refs = self.set_itemrefs()
     igd.ItemRef = item_refs
     parser = ODM_PARSER.ODMParser(self.test_file, self.nsr)
     parser.parse()
     mdv = parser.MetaDataVersion()
     igd_list = parser.ItemGroupDef(parent=mdv[0])
     igd_dict = igd_list[0]
     self.assertEqual(igd_dict["OID"], "IG.TA")
     ir_list = parser.ItemRef(parent=igd_dict["elem"])
     # tests the __len__ in ItemGroupDef as well as the add_item_ref
     self.assertEqual(len(ir_list), len(igd))
Exemple #10
0
 def test_to_xml(self):
     attrs = self.set_itemgroupdef_attributes()
     igd = DEFINE.ItemGroupDef(**attrs)
     tt = DEFINE.TranslatedText(
         _content="this is the first test description", lang="en")
     desc = DEFINE.Description()
     desc.TranslatedText = [tt]
     igd.Description = desc
     ir1 = DEFINE.ItemRef(ItemOID="IT.STUDYID",
                          Mandatory="Yes",
                          OrderNumber=1)
     ir2 = DEFINE.ItemRef(ItemOID="IT.VS.VSTEST",
                          Mandatory="No",
                          OrderNumber=2)
     igd.ItemRef = [ir1, ir2]
     igd_xml = igd.to_xml()
     self.assertEqual(igd_xml.attrib["OID"], "IG.VS")
     self.assertListEqual(["Description", "ItemRef", "ItemRef"],
                          [e.tag for e in igd_xml.getchildren()])
Exemple #11
0
 def test_to_json(self):
     attrs = self.set_itemgroupdef_attributes()
     igd = DEFINE.ItemGroupDef(**attrs)
     tt = DEFINE.TranslatedText(
         _content="this is the first test description", lang="en")
     igd.Description = DEFINE.Description()
     igd.Description.TranslatedText = [tt]
     ir1 = DEFINE.ItemRef(ItemOID="IT.STUDYID",
                          Mandatory="Yes",
                          OrderNumber=1)
     ir2 = DEFINE.ItemRef(ItemOID="IT.VS.VSTEST",
                          Mandatory="No",
                          OrderNumber=2)
     igd.ItemRef = [ir1, ir2]
     igd_json = igd.to_json()
     igd_dict = json.loads(igd_json)
     print(igd_dict)
     self.assertEqual(igd_dict["OID"], "IG.VS")
     self.assertEqual(igd_dict["ItemRef"][1]["ItemOID"], "IT.VS.VSTEST")