def test_to_json(self): attrs = self.set_item_attributes() item = DEFINE.ItemDef(**attrs) item.Description.TranslatedText.append(DEFINE.TranslatedText(_content="this is the first test description", lang="en")) item.Question.TranslatedText = [DEFINE.TranslatedText(_content="Any AEs?", lang="en")] item.CodeListRef = DEFINE.CodeListRef(CodeListOID="CL.NY_SUB_Y_N_2011-10-24") item_json = item.to_json() item_dict = json.loads(item_json) self.assertEqual(item_dict["OID"], "ODM.IT.AE.AEYN")
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_xml(self): attrs = self.set_item_attributes() item = DEFINE.ItemDef(**attrs) item.Description.TranslatedText = [DEFINE.TranslatedText(_content="this is the first test description", lang="en")] item.CodeListRef = DEFINE.CodeListRef(CodeListOID="CL.NY_SUB_Y_N_2011-10-24") item.RangeCheck = [DEFINE.RangeCheck(Comparator="EQ", SoftHard="Soft", ItemOID="IT.DA.DAORRES")] item.RangeCheck[0].CheckValue = [DEFINE.CheckValue(_content="DIABP")] item_xml = item.to_xml() self.assertEqual(item_xml.attrib["OID"], "ODM.IT.AE.AEYN") cv = item_xml.find("*/CheckValue") self.assertEqual(cv.text, "DIABP") dt = item_xml.findall("Description/TranslatedText") self.assertEqual(len(dt), 1)
def test_to_dict(self): attrs = self.set_item_attributes() item = DEFINE.ItemDef(**attrs) item.Description.TranslatedText = [DEFINE.TranslatedText(_content="this is the first test description", lang="en")] item.Question.TranslatedText = [DEFINE.TranslatedText(_content="Any AEs?", lang="en")] item.CodeListRef = DEFINE.CodeListRef(CodeListOID="CL.NY_SUB_Y_N_2011-10-24") item_dict = item.to_dict() expected_dict = {'OID': 'ODM.IT.AE.AEYN', 'Name': 'Any AEs?', 'DataType': 'text', 'Length': 1, 'SASFieldName': 'AEYN', "CommentOID": "ODM.CO.120", 'Description': {'TranslatedText': [{'_content': 'this is the first test description', 'lang': 'en'}]}, 'Question': {'TranslatedText': [{'_content': 'Any AEs?', 'lang': 'en'}]}, 'CodeListRef': {'CodeListOID': 'CL.NY_SUB_Y_N_2011-10-24'}} self.assertDictEqual(item_dict, expected_dict)
def setUp(self) -> None: attrs = self.set_item_attributes() self.item = DEFINE.ItemDef(**attrs)
def test_invalid_attribute_data_type(self): attrs = {"OID": "ODM.IT.AE.AEYN", "Name": "Any AEs?", "DataType": "text", "SignificantDigits": "A"} with self.assertRaises(TypeError): self.item = DEFINE.ItemDef(**attrs)
def test_missing_itemdef_attributes(self): attrs = {"OID": "ODM.IT.AE.AEYN", "Name": "Any AEs?"} with self.assertRaises(ValueError): DEFINE.ItemDef(**attrs)
def test_required_attributes_only(self): attrs = {"OID": "ODM.IT.AE.AEYN", "Name": "Any AEs?", "DataType": "text"} self.item = DEFINE.ItemDef(**attrs) self.assertEqual(self.item.OID, "ODM.IT.AE.AEYN")