Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

72 lines
3.5 KiB

import unittest
#import basic.program
import utils.xml_tool
import utils.xml_tool
class MyTestCase(unittest.TestCase):
def xtest_xmlTool(self):
#job = basic.program.Job("unit")
args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug",
"tool": "job_tool", "tdtyp": "csv", "tdsrc": "implement", "tdname": "firstunit",
"modus": "unit"}
beispiel_json = {'root': {'@attr': 'xyz', '$': 'inhalt', "b": "bold"}}
tree = {}
tree["root"] = args
xml = utils.xml_tool.dict2xml(tree)
print(xml)
xml = utils.xml_tool.dict2xml(beispiel_json)
print(xml)
self.assertEqual(1, 1)
f = utils.xml_tool.fcts()
def xtest_addSingle(self):
tree = {}
# tree = utils.xml_tool.fcts.addMerkmal(tree, '/root/datensegment/satz[@klasse="4711x"]/mm[@name="NAME"]/wert', 2, "abc")
tree = utils.xml_tool.fcts.addMerkmal(tree, '/root/datensegment/kratz/mm[@name="NAME"]/wert', 2, "abc")
self.assertEqual(tree["kratz"]["mm"][0]["wert"], "abc")
self.assertEqual(tree["kratz"]["mm"][0]["@name"], "NAME")
def xtest_addTwo(self):
# a-b-b
# c-a-a c-a-b
tree = {}
print("--------------------------------------------------------------------------------")
tree = utils.xml_tool.fcts.addMerkmal(tree, '/root/datensegment/kratz/mm[@name="NAME"]/wert', 2, "abc")
print("--------------------------------------------------------------------------------")
tree = utils.xml_tool.fcts.addMerkmal(tree, '/root/datensegment/kratz/mm[@name="LAND"]/wert', 2, "xyz")
baum = {}
baum["root"] = tree
print("<------"+str(baum["root"]))
self.assertEqual(tree["kratz"]["mm"][0]["wert"], "abc")
self.assertEqual(tree["kratz"]["mm"][0]["@name"], "NAME")
self.assertEqual(tree["kratz"]["mm"][1]["wert"], "xyz")
self.assertEqual(tree["kratz"]["mm"][1]["@name"], "LAND")
def xtest_addOnePaths(self):
tree = {}
print("--------------------------------------------------------------------------------")
tree = utils.xml_tool.fcts.setMerkmal(tree, '/root/datensegment/satz[@klasse="4711x"]/mm[@name="NAME"]/wert', "abc")
baum = {}
baum["root"] = tree
print("<------"+str(baum["root"]))
self.assertEqual(tree["root"]["datensegment"]["satz"][0]["mm"][0]["wert"], "abc")
self.assertEqual(tree["root"]["datensegment"]["satz"][0]["mm"][0]["@name"], "NAME")
self.assertEqual(tree["root"]["datensegment"]["satz"][0]["@klasse"], "4711x")
def test_addTwoPaths(self):
tree = {}
print("--------------------------------------------------------------------------------")
tree = utils.xml_tool.fcts.setMerkmal(tree, '/root/datensegment/satz[@klasse="4711x"]/mm[@name="NAME"]/wert', "abc")
print("--------------------------------------------------------------------------------")
tree = utils.xml_tool.fcts.setMerkmal(tree, '/root/datensegment/satz[@klasse="4711x"]/mm[@name="LAND"]/wert', "xyz")
baum = {}
baum["root"] = tree
print("<------"+str(baum["root"]))
self.assertEqual(tree["root"]["datensegment"]["satz"][0]["mm"][0]["wert"], "abc")
self.assertEqual(tree["root"]["datensegment"]["satz"][0]["mm"][0]["@name"], "NAME")
self.assertEqual(tree["root"]["datensegment"]["satz"][0]["@klasse"], "4711x")
if __name__ == '__main__':
unittest.main()