Beispiel #1
0
 def test_add_code_list_item(self):
     cli1 = ODM.CodeListItem(CodedValue="HGB", OrderNumber=1)
     cli1.Alias.append(ODM.Alias(Context="nci:ExtCodeID", Name="C64848"))
     self.cl.CodeListItem.append(cli1)
     cli2 = ODM.CodeListItem(CodedValue="VITB12", OrderNumber=2)
     cli2.Alias.append(ODM.Alias(Context="nci:ExtCodeID", Name="C64817"))
     self.cl.CodeListItem.append(cli2)
     cli3 = ODM.CodeListItem(CodedValue="GLUC", OrderNumber=3)
     cli3.Alias = [ODM.Alias(Context="nci:ExtCodeID", Name="C41376")]
     self.cl.CodeListItem.append(cli3)
     cl_dict = self.cl.to_dict()
     print(cl_dict)
     self.assertDictEqual(cl_dict, self.expected_cli_dict())
Beispiel #2
0
 def add_CL(self):
     tt1 = ODM.TranslatedText(_content="No", lang="en")
     dc1 = ODM.Decode()
     dc1.TranslatedText = [tt1]
     cli1 = ODM.CodeListItem(CodedValue="N")
     cli1.Decode = dc1
     tt2 = ODM.TranslatedText(_content="Yes", lang="en")
     dc2 = ODM.Decode()
     dc2.TranslatedText = [tt2]
     cli2 = ODM.CodeListItem(CodedValue="Y")
     cli2.Decode = dc2
     cl = ODM.CodeList(OID="ODM.CL.NY_SUB_Y_N",
                       Name="No Yes Response",
                       DataType="text")
     cl.CodeListItem = [cli1, cli2]
     return [cl]
Beispiel #3
0
 def test_to_xml_code_list_item(self):
     attrs = self._set_attributes()
     cl = ODM.CodeList(**attrs)
     cli1 = ODM.CodeListItem(CodedValue="HGB", OrderNumber=1)
     cli1.Alias = [ODM.Alias(Context="nci:ExtCodeID", Name="C64848")]
     cl.CodeListItem.append(cli1)
     cli2 = ODM.CodeListItem(CodedValue="VITB12", OrderNumber=2)
     cli2.Alias.append(ODM.Alias(Context="nci:ExtCodeID", Name="C64817"))
     cl.CodeListItem.append(cli2)
     cli3 = ODM.CodeListItem(CodedValue="GLUC", OrderNumber=3)
     cli3.Alias.append(ODM.Alias(Context="nci:ExtCodeID", Name="C41376"))
     cl.CodeListItem.append(cli3)
     cl_xml = cl.to_xml()
     self.assertEqual(cl_xml.attrib["OID"], "ODM.CL.LBTESTCD")
     ei = cl_xml.findall("CodeListItem")
     self.assertEqual(ei[0].attrib["CodedValue"], "HGB")
Beispiel #4
0
 def test_integer_type(self):
     # order number is an integer - test as an integer
     attrs = {"CodedValue": "HGB", "OrderNumber": 1}
     cli = ODM.CodeListItem(**attrs)
     self.assertEqual(cli.OrderNumber, 1)
     # test integer as string
     attrs = {"CodedValue": "HGB", "OrderNumber": "1"}
     cli = ODM.CodeListItem(**attrs)
     self.assertEqual(cli.OrderNumber, 1)
     # test integer as float
     attrs = {"CodedValue": "HGB", "OrderNumber": 1.1}
     with self.assertRaises(TypeError):
         cli = ODM.CodeListItem(**attrs)
     # test non-integer as
     attrs = {"CodedValue": "HGB", "OrderNumber": "a"}
     with self.assertRaises(TypeError):
         cli = ODM.CodeListItem(**attrs)
Beispiel #5
0
 def test_CodeListItem(self):
     cli = ODM.CodeListItem(CodedValue="HGB", OrderNumber="1")
     tt1 = ODM.TranslatedText(_content="Hemoglobin", lang="en")
     decode = ODM.Decode()
     decode.TranslatedText.append(tt1)
     cli.Decode = decode
     cli.Alias.append(ODM.Alias(Context="nci:ExtCodeID", Name="C64848"))
     cli_dict = cli.to_dict()
     print(cli_dict)
     is_valid = self.validator.verify_conformance(cli_dict, "CodeListItem")
     self.assertTrue(is_valid)
Beispiel #6
0
 def test_float_type(self):
     # rank is a float - test as a float
     attrs = {"CodedValue": "HGB", "Rank": 1.1}
     cli = ODM.CodeListItem(**attrs)
     self.assertEqual(cli.Rank, 1.1)
     # test float as string
     attrs = {"CodedValue": "HGB", "Rank": "1.1"}
     cli = ODM.CodeListItem(**attrs)
     self.assertEqual(cli.Rank, 1.1)
     # test integer as float
     attrs = {"CodedValue": "HGB", "Rank": 1}
     cli = ODM.CodeListItem(**attrs)
     self.assertEqual(cli.Rank, 1.0)
     # test non-float as string
     attrs = {"CodedValue": "HGB", "Rank": "a"}
     with self.assertRaises(TypeError):
         cli = ODM.CodeListItem(**attrs)
     # test object as float
     clr = ODM.CodeListRef(CodeListOID="CL.TEST")
     attrs = {"CodedValue": "HGB", "Rank": clr}
     with self.assertRaises(TypeError):
         cli = ODM.CodeListItem(**attrs)