Beispiel #1
0
 def set_itemrefs(self):
     """
     set some ItemRef element attributes using test data
     :return: return a list of ItemRef named tuples
     """
     itemrefs = []
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.STUDYID",
                        Mandatory="Yes",
                        OrderNumber=1,
                        KeySequence=1))
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.TA.DOMAIN",
                        Mandatory="Yes",
                        OrderNumber=2))
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.TA.ARMCD",
                        Mandatory="Yes",
                        OrderNumber=3,
                        KeySequence=2))
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.TA.ARM", Mandatory="Yes",
                        OrderNumber=4))
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.TA.TAETORD",
                        Mandatory="Yes",
                        OrderNumber=5,
                        KeySequence=3))
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.TA.ETCD",
                        Mandatory="Yes",
                        OrderNumber=6))
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.TA.ELEMENT",
                        Mandatory="No",
                        OrderNumber=7))
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.TA.TABRANCH",
                        Mandatory="No",
                        OrderNumber=8))
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.TA.TATRANS",
                        Mandatory="No",
                        OrderNumber=9))
     itemrefs.append(
         DEFINE.ItemRef(ItemOID="IT.TA.EPOCH",
                        Mandatory="No",
                        OrderNumber=10))
     return itemrefs
Beispiel #2
0
 def test_item_ref_exists(self):
     self.igd.ItemRef = [
         DEFINE.ItemRef(ItemOID="IT.VS.VSTESTCD",
                        Mandatory="Yes",
                        OrderNumber=4)
     ]
     self.assertEqual(self.igd.ItemRef[0].ItemOID, "IT.VS.VSTESTCD")
Beispiel #3
0
 def test_add_item_ref_invalid_kwarg(self):
     with self.assertRaises(TypeError):
         self.igd.ItemRef = [
             DEFINE.ItemRef(ItemOID="IT.STUDYID",
                            Mandatory="Yes",
                            InValid="Yes")
         ]
Beispiel #4
0
 def test_add_item_ref_list(self):
     ir1 = DEFINE.ItemRef(ItemOID="IT.STUDYID",
                          Mandatory="Yes",
                          OrderNumber=1)
     self.igd.ItemRef.append(ir1)
     ir2 = DEFINE.ItemRef(ItemOID="IT.VS.VSTEST",
                          Mandatory="No",
                          OrderNumber=2)
     self.igd.ItemRef.append(ir2)
     ir3 = DEFINE.ItemRef(ItemOID="IT.VS.VSORRES",
                          Mandatory="Yes",
                          OrderNumber=3,
                          MethodOID="MT.METHODFEX")
     self.igd.ItemRef.append(ir3)
     self.assertEqual(self.igd.ItemRef[0].ItemOID, "IT.STUDYID")
     self.assertEqual(self.igd.ItemRef[2].MethodOID, "MT.METHODFEX")
Beispiel #5
0
 def test_value_list_def(self):
     vld = DEFINE.ValueListDef(OID="VL.DA.DAORRES")
     vld.ItemRef.append(
         DEFINE.ItemRef(ItemOID="IT.DA.DAORRES.DISPAMT",
                        OrderNumber="1",
                        Mandatory="Yes"))
     vld.ItemRef[0].WhereClauseRef.append(
         DEFINE.WhereClauseRef(WhereClauseOID="WC.DA.DATESTCD.DISPAMT"))
     vld.ItemRef.append(
         DEFINE.ItemRef(ItemOID="IT.DA.DAORRES.RETAMT",
                        OrderNumber="2",
                        Mandatory="No"))
     vld.ItemRef[1].WhereClauseRef.append(
         DEFINE.WhereClauseRef(WhereClauseOID="WC.DA.DATESTCD.RETAMT"))
     self.assertEqual("WC.DA.DATESTCD.RETAMT",
                      vld.ItemRef[1].WhereClauseRef[0].WhereClauseOID)
     vld_dict = vld.to_dict()
     print(vld_dict)
     expected_dict = {
         'OID':
         'VL.DA.DAORRES',
         'ItemRef': [{
             'ItemOID':
             'IT.DA.DAORRES.DISPAMT',
             'OrderNumber':
             1,
             'Mandatory':
             'Yes',
             'WhereClauseRef': [{
                 'WhereClauseOID': 'WC.DA.DATESTCD.DISPAMT'
             }]
         }, {
             'ItemOID':
             'IT.DA.DAORRES.RETAMT',
             'OrderNumber':
             2,
             'Mandatory':
             'No',
             'WhereClauseRef': [{
                 'WhereClauseOID': 'WC.DA.DATESTCD.RETAMT'
             }]
         }]
     }
     self.assertDictEqual(vld_dict, expected_dict)
Beispiel #6
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()])
Beispiel #7
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")
Beispiel #8
0
 def test_add_item_ref_missing_kwarg(self):
     with self.assertRaises(ValueError):
         self.igd.ItemRef = [DEFINE.ItemRef(Mandatory="Yes", OrderNumber=1)]