Browse Source

bugfixes on unit-tests

master
Ulrich Carmesin 2 years ago
parent
commit
1347256e23
  1. 2
      basic/catalog.py
  2. 6
      basic/compexec.py
  3. 12
      basic/componentHandling.py
  4. 4
      basic/message.py
  5. 9
      basic/program.py
  6. 10
      basic/step.py
  7. 2
      check_environment.py
  8. 2
      collect_testcase.py
  9. 2
      compare_testcase.py
  10. 2
      declare_result.py
  11. 2
      execute_testcase.py
  12. 2
      finish_testsuite.py
  13. 4
      init_testcase.py
  14. 17
      requirements.txt
  15. 22
      test/test_03path.py
  16. 8
      test/test_04config.py
  17. 8
      test/test_08i18n.py
  18. 11
      test/test_11component.py
  19. 33
      test/test_21tdata.py
  20. 12
      test/test_22compare.py
  21. 25
      test/test_23report.py
  22. 8
      test/test_25map.py
  23. 5
      test/test_31db.py
  24. 8
      test/test_32file.py
  25. 2
      test/test_71job.py
  26. 5
      test/testtools.py
  27. 3
      utils/cli_abstract.py
  28. 8
      utils/config_tool.py
  29. 1
      utils/file_tool.py
  30. 10
      utils/i18n_tool.py
  31. 6
      utils/match_tool.py
  32. 16
      utils/path_tool.py
  33. 28
      utils/report_tool.py
  34. 34
      utils/tdata_tool.py

2
basic/catalog.py

@ -90,7 +90,7 @@ class Catalog:
raise Exception(EXP_KEY_MISSING, (domain)) raise Exception(EXP_KEY_MISSING, (domain))
if domain in self.catalog: if domain in self.catalog:
return return
pathname = utils.config_tool.getConfigPath(P.KEY_CATALOG, domain, job) pathname = utils.config_tool.getConfigPath(job, P.KEY_CATALOG, domain)
if pathname is None: if pathname is None:
raise Exception(EXP_KEY_MISSING, (domain)) raise Exception(EXP_KEY_MISSING, (domain))
if pathname[-4:] == ".csv": if pathname[-4:] == ".csv":

6
basic/compexec.py

@ -128,7 +128,7 @@ class Testexecuter():
""" """
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel(self.name) verify = -1+job.getDebugLevel(self.name)
self.read_TData(job, utils.path_tool.getKeyValue(P.KEY_PRECOND), B.PAR_TESTCASE) self.read_TData(job, utils.path_tool.getKeyValue(job, P.KEY_PRECOND), B.PAR_TESTCASE)
def read_TData(self, job, subdir, granularity): def read_TData(self, job, subdir, granularity):
""" """
@ -202,7 +202,7 @@ class Testexecuter():
print("table "+table) print("table "+table)
sql_new = sql[0:sql.upper().index(" FROM ")+5] sql_new = sql[0:sql.upper().index(" FROM ")+5]
print("sql_new "+sql_new) print("sql_new "+sql_new)
attr = utils.db_abstract.getDbAttributes(self, job, table) attr = utils.db_abstract.getDbAttributes(self, table)
if attr[B.ATTR_DB_TABNAME] != "": if attr[B.ATTR_DB_TABNAME] != "":
table = attr[B.ATTR_DB_TABNAME] table = attr[B.ATTR_DB_TABNAME]
if attr[B.ATTR_DB_SCHEMA] != "": if attr[B.ATTR_DB_SCHEMA] != "":
@ -351,7 +351,7 @@ class Testexecuter():
""" """
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name) verify = job.getDebugLevel(self.name)
cm = basic.componentHandling.ComponentManager.getInstance() cm = basic.componentHandling.ComponentManager.getInstance(job)
data = {} data = {}
matching = utils.match_tool.Matching(job, self) matching = utils.match_tool.Matching(job, self)
if B.TOPIC_NODE_DB in self.conf[B.SUBJECT_ARTS]: if B.TOPIC_NODE_DB in self.conf[B.SUBJECT_ARTS]:

12
basic/componentHandling.py

@ -63,6 +63,7 @@ def getComponents(job, mainfct):
class ComponentManager: class ComponentManager:
__instance = None __instance = None
__instances = {}
""" """
initializes the Manager with all necessary components initializes the Manager with all necessary components
""" """
@ -73,6 +74,7 @@ class ComponentManager:
self.components = {} self.components = {}
self.comps = {} self.comps = {}
self.job = job self.job = job
ComponentManager.__instances[job.jobid] = self
ComponentManager.__instance = self ComponentManager.__instance = self
print ("init ComponentHandling "+str(self)) print ("init ComponentHandling "+str(self))
@ -117,13 +119,11 @@ class ComponentManager:
@staticmethod @staticmethod
def getInstance(init="N"): def getInstance(job, init="N"):
if (ComponentManager.__instance is not None): if (job.jobid in ComponentManager.__instances):
return ComponentManager.__instance return ComponentManager.__instances[job.jobid]
elif (init != "N"):
return ComponentManager()
else: else:
raise Exception(B.EXCEPT_NOT_INITIALIZED) return ComponentManager(job)
def createComponent(self, componentName, nr, suffix): def createComponent(self, componentName, nr, suffix):

4
basic/message.py

@ -95,7 +95,7 @@ class Message:
basedir = job.par.basedir basedir = job.par.basedir
basedir = basedir.replace("base", "log") basedir = basedir.replace("base", "log")
# basedir = utils.path_tool.composePath(basedir, None) # basedir = utils.path_tool.composePath(basedir, None)
basedir = utils.path_tool.composePath(basedir, None) basedir = utils.path_tool.composePath(job, basedir, None)
os.makedirs(basedir, exist_ok=True) os.makedirs(basedir, exist_ok=True)
logpath = os.path.join(basedir , job.program + "_" + logTime + ".txt") logpath = os.path.join(basedir , job.program + "_" + logTime + ".txt")
self.logDebug("logfile " + logpath) self.logDebug("logfile " + logpath)
@ -200,7 +200,7 @@ class Message:
for i in range(0, len(T.LIST_EXP_TEXT)): for i in range(0, len(T.LIST_EXP_TEXT)):
if text == T.LIST_EXP_TEXT[i]: if text == T.LIST_EXP_TEXT[i]:
constName = T.LIST_EXP_CONST[i] constName = T.LIST_EXP_CONST[i]
txt = utils.i18n_tool.I18n.getInstance().getMessage(self.job, constName, args) txt = utils.i18n_tool.I18n.getInstance(job).getMessage(self.job, constName, args)
out = txt.format(args) out = txt.format(args)
return out return out

9
basic/program.py

@ -185,9 +185,12 @@ def createJob(pprg="", pgran="", papp="", penv="", ptstamp="", pmode=""):
class Job: class Job:
__instance = None __instance = None
__instances = [] __instances = []
__jobid = 100000
def __init__ (self, program): def __init__ (self, program):
print ("################# init Job ## " + program + " #################") print ("################# init Job ## " + program + " #################")
Job.__jobid += 1
self.jobid = str(Job.__jobid)
self.program = program self.program = program
Job.__instance = self Job.__instance = self
if Job.__instances is None: if Job.__instances is None:
@ -259,7 +262,7 @@ class Job:
def dumpParameter(self): def dumpParameter(self):
parpath = utils.path_tool.composePath(jobdef[self.program]["pfiletarget"], None) parpath = utils.path_tool.composePath(self, jobdef[self.program]["pfiletarget"], None)
output = {} output = {}
cconf = basic.componentHandling.getComponentDict() cconf = basic.componentHandling.getComponentDict()
output["par"] = self.par.__dict__ output["par"] = self.par.__dict__
@ -282,7 +285,7 @@ class Job:
output = {} output = {}
if len(str(jobdef[self.program]["pfilesource"])) < 2: if len(str(jobdef[self.program]["pfilesource"])) < 2:
return None return None
parpath = utils.path_tool.composePath(jobdef[self.program]["pfilesource"], None) parpath = utils.path_tool.composePath(self, jobdef[self.program]["pfilesource"], None)
if not os.path.join(parpath): if not os.path.join(parpath):
return None return None
doc = utils.file_tool.readFileDict(self, parpath, self.m) doc = utils.file_tool.readFileDict(self, parpath, self.m)
@ -460,7 +463,7 @@ class Parameter:
self.setJobAttr(k , getattr(args, k)) self.setJobAttr(k , getattr(args, k))
dirpath = self.getDirParameter() dirpath = self.getDirParameter()
if dirpath is not None: if dirpath is not None:
utils.path_tool.extractPath(dirpath[0], dirpath[1]) utils.path_tool.extractPath(job, dirpath[0], dirpath[1])
app = self.application app = self.application
if self.application in job.conf.confs[B.SUBJECT_APPS]: if self.application in job.conf.confs[B.SUBJECT_APPS]:
if B.ATTR_APPS_PROJECT in job.conf.confs[B.SUBJECT_APPS][self.application]: if B.ATTR_APPS_PROJECT in job.conf.confs[B.SUBJECT_APPS][self.application]:

10
basic/step.py

@ -99,11 +99,11 @@ def parseStep(job, fields):
def getStepHeader(job): def getStepHeader(job):
text = "# " text = "# "
text += utils.i18n_tool.I18n.getInstance().getText(f"{D.CSV_BLOCK_STEP=}", job) text += utils.i18n_tool.I18n.getInstance(job).getText(f"{D.CSV_BLOCK_STEP=}", job)
text += ";"+utils.i18n_tool.I18n.getInstance().getText(f"{D.STEP_ATTR_COMP=}", job) text += ";"+utils.i18n_tool.I18n.getInstance(job).getText(f"{D.STEP_ATTR_COMP=}", job)
text += ";"+utils.i18n_tool.I18n.getInstance().getText(f"{D.STEP_ATTR_EXECNR=}", job) text += ";"+utils.i18n_tool.I18n.getInstance(job).getText(f"{D.STEP_ATTR_EXECNR=}", job)
text += ";"+utils.i18n_tool.I18n.getInstance().getText(f"{D.STEP_ATTR_REFNR=}", job) text += ";"+utils.i18n_tool.I18n.getInstance(job).getText(f"{D.STEP_ATTR_REFNR=}", job)
text += ";"+utils.i18n_tool.I18n.getInstance().getText(f"{D.STEP_ATTR_ARGS=}", job) text += ";"+utils.i18n_tool.I18n.getInstance(job).getText(f"{D.STEP_ATTR_ARGS=}", job)
return text + ";..;;;\n" return text + ";..;;;\n"

2
check_environment.py

@ -19,7 +19,7 @@ if __name__ == '__main__':
exit(x.m.rc * (-1) + 3) exit(x.m.rc * (-1) + 3)
# now in theory the program is runnable # now in theory the program is runnable
x.m.setMsg("# job initialized") x.m.setMsg("# job initialized")
cm = basic.componentHandling.ComponentManager() cm = basic.componentHandling.ComponentManager.getInstance(job)
print("cm "+str(cm)) print("cm "+str(cm))
cm.initComponents() cm.initComponents()
comps = cm.getComponents(x, PROGRAM_NAME) comps = cm.getComponents(x, PROGRAM_NAME)

2
collect_testcase.py

@ -16,7 +16,7 @@ import utils.tdata_tool
PROGRAM_NAME = "collect_testcase" PROGRAM_NAME = "collect_testcase"
def startPyJob(job): def startPyJob(job):
cm = basic.componentHandling.ComponentManager.getInstance("init") cm = basic.componentHandling.ComponentManager.getInstance(job)
cm.initComponents() cm.initComponents()
comps = cm.getComponents(job, PROGRAM_NAME) comps = cm.getComponents(job, PROGRAM_NAME)
print(" relevant components for this job: " + str(comps)) print(" relevant components for this job: " + str(comps))

2
compare_testcase.py

@ -20,7 +20,7 @@ import basic.message as message
PROGRAM_NAME = "compare_testcase" PROGRAM_NAME = "compare_testcase"
def startPyJob(job): def startPyJob(job):
cm = basic.componentHandling.ComponentManager(job, "init") cm = basic.componentHandling.ComponentManager.getInstance(job)
print("cm "+str(cm)) print("cm "+str(cm))
cm.initComponents() cm.initComponents()
comps = cm.getComponents(PROGRAM_NAME) comps = cm.getComponents(PROGRAM_NAME)

2
declare_result.py

@ -26,7 +26,7 @@ if __name__ == '__main__':
x.m.logInfo("hier eine LogInfo") x.m.logInfo("hier eine LogInfo")
x.m.logDebug("hier eine DbugMeldung") x.m.logDebug("hier eine DbugMeldung")
x.m.logDebug(str(vars(x.par)) + "\n" + str(vars(x.conf))) x.m.logDebug(str(vars(x.par)) + "\n" + str(vars(x.conf)))
cm = ComponentManager() cm = ComponentManager.getInstance(x)
if x.m.isRc("fatal"): if x.m.isRc("fatal"):
x.stopJob() x.stopJob()
exit(x.m.rc * (-1) + 3) exit(x.m.rc * (-1) + 3)

2
execute_testcase.py

@ -22,7 +22,7 @@ import basic.message as message
PROGRAM_NAME = "execute_testcase" PROGRAM_NAME = "execute_testcase"
def startPyJob(job): def startPyJob(job):
cm = basic.componentHandling.ComponentManager(job) cm = basic.componentHandling.ComponentManager.getInstance(job)
print("cm "+str(cm)) print("cm "+str(cm))
cm.initComponents() cm.initComponents()
comps = cm.getComponents(PROGRAM_NAME) comps = cm.getComponents(PROGRAM_NAME)

2
finish_testsuite.py

@ -15,7 +15,7 @@ import utils.zip_tool
PROGRAM_NAME = "finish_testsuite" PROGRAM_NAME = "finish_testsuite"
def startPyJob(job): def startPyJob(job):
cm = basic.componentHandling.ComponentManager.getInstance("init") cm = basic.componentHandling(job)
report = utils.report_tool.Report() report = utils.report_tool.Report()
testinstances = {} testinstances = {}
if hasattr(job.par, "testinstances"): if hasattr(job.par, "testinstances"):

4
init_testcase.py

@ -19,7 +19,7 @@ import basic.message as message
PROGRAM_NAME = "init_testcase" PROGRAM_NAME = "init_testcase"
def startPyJob(job): def startPyJob(job):
cm = basic.componentHandling.ComponentManager.getInstance(job, "init") cm = basic.componentHandling.ComponentManager.getInstance(job)
cm.initComponents() cm.initComponents()
comps = cm.getComponents(PROGRAM_NAME) comps = cm.getComponents(PROGRAM_NAME)
job.m.setMsg("# Components initialized with these relevant components " + str(comps)) job.m.setMsg("# Components initialized with these relevant components " + str(comps))
@ -33,7 +33,7 @@ def startPyJob(job):
if job.hasFunction("load_TData"): if job.hasFunction("load_TData"):
comp.load_TData(job, B.PAR_TESTCASE, testdata) comp.load_TData(job, B.PAR_TESTCASE, testdata)
if job.hasFunction("read_TData"): if job.hasFunction("read_TData"):
comp.read_TData(job, utils.path_tool.getKeyValue(P.KEY_PRECOND), B.PAR_TESTCASE) comp.read_TData(job, utils.path_tool.getKeyValue(job, P.KEY_PRECOND), B.PAR_TESTCASE)
comp.m.logInfo("------- "+comp.name+" ----------------------------------------") comp.m.logInfo("------- "+comp.name+" ----------------------------------------")
job.m.merge(comp.m) job.m.merge(comp.m)
print(str(comp)) print(str(comp))

17
requirements.txt

@ -1,2 +1,15 @@
pyyaml pyyaml~=6.0
paramiko paramiko~=2.9.2
cryptography~=36.0.1
pip~=21.3.1
MarkupSafe~=2.1.1
Werkzeug~=2.2.2
Jinja2~=3.1.2
click~=8.1.3
itsdangerous~=2.1.2
setuptools~=60.5.0
zipp~=3.8.1
xmltodict~=0.12.0
pyspark~=3.2.1
Flask~=2.2.2

22
test/test_03path.py

@ -42,11 +42,11 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
res = utils.path_tool.getKeyValue("job.par."+B.PAR_ENV, None) res = utils.path_tool.getKeyValue(job, "job.par."+B.PAR_ENV, None)
self.assertEqual(res, test.testtools.DEFAULT_ENV) self.assertEqual(res, test.testtools.DEFAULT_ENV)
cnttest += 1 cnttest += 1
for par in [B.ATTR_PATH_ARCHIV, B.ATTR_PATH_ENV]: for par in [B.ATTR_PATH_ARCHIV, B.ATTR_PATH_ENV]:
res = utils.path_tool.getKeyValue("job.conf."+par, None) res = utils.path_tool.getKeyValue(job, "job.conf."+par, None)
if verbose: print("assertIn "+par+": "+res+" -- "+DATA_PATH) if verbose: print("assertIn "+par+": "+res+" -- "+DATA_PATH)
self.assertIn(DATA_PATH, res) self.assertIn(DATA_PATH, res)
cnttest += 1 cnttest += 1
@ -80,16 +80,16 @@ class MyTestCase(unittest.TestCase):
return return
# set the relevant datastrutures # set the relevant datastrutures
job = test.testtools.getJob() job = test.testtools.getJob()
comp = test.testtools.getComp(job) comp = test.testtools.getComp(job, "testrest")
pt = utils.path_tool.PathConf() pt = utils.path_tool.PathConf(job)
self.setTestPaths(job) self.setTestPaths(job)
self.setPathConfig(pt) self.setPathConfig(pt)
# tests # tests
path = utils.path_tool.composePath(P.P_ENVBASE, None) path = utils.path_tool.composePath(job, P.P_ENVBASE, None)
self.assertIn(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ENV], path) self.assertIn(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ENV], path)
self.assertIn(getattr(job.par, B.PAR_ENV), path) self.assertIn(getattr(job.par, B.PAR_ENV), path)
cnttest += 2 cnttest += 2
path = utils.path_tool.composePath(P.P_TCLOG, None) path = utils.path_tool.composePath(job, P.P_TCLOG, None)
self.assertIn(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV], path) self.assertIn(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV], path)
self.assertIn(getattr(job.par, B.PAR_TESTCASE), path) self.assertIn(getattr(job.par, B.PAR_TESTCASE), path)
cnttest += 2 cnttest += 2
@ -105,7 +105,7 @@ class MyTestCase(unittest.TestCase):
# set the relevant datastrutures # set the relevant datastrutures
job = test.testtools.getJob() job = test.testtools.getJob()
comp = test.testtools.getComp(job) comp = test.testtools.getComp(job)
pt = utils.path_tool.PathConf() pt = utils.path_tool.PathConf(job)
self.setTestPaths(job) self.setTestPaths(job)
self.setPathConfig(pt) self.setPathConfig(pt)
# tests # tests
@ -123,9 +123,9 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
pt = utils.path_tool.PathConf() pt = utils.path_tool.PathConf(job)
job = test.testtools.getJob("ts", test.testtools.DEFAULT_APP, test.testtools.DEFAULT_ENV, "2021-08-21_18-ß2-01") job = test.testtools.getJob("ts", test.testtools.DEFAULT_APP, test.testtools.DEFAULT_ENV, "2021-08-21_18-ß2-01")
r = utils.path_tool.extractPattern("tsbase" ) r = utils.path_tool.extractPattern(job, "tsbase" )
self.assertEqual(r[0][1], "job.conf.archiv") self.assertEqual(r[0][1], "job.conf.archiv")
self.assertEqual(r[1][1], P.KEY_TESTSUITE) self.assertEqual(r[1][1], P.KEY_TESTSUITE)
self.assertEqual(r[1][2], "testlauf") self.assertEqual(r[1][2], "testlauf")
@ -140,8 +140,8 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
pt = utils.path_tool.PathConf() pt = utils.path_tool.PathConf(job)
r = utils.path_tool.extractPath("tsbase" , os.path.join(DATA_PATH, "lauf", "testlauf", "startjob_2021-08-21_10-02-01")) r = utils.path_tool.extractPath(job, "tsbase" , os.path.join(DATA_PATH, "lauf", "testlauf", "startjob_2021-08-21_10-02-01"))
if verbose: print("r " + str(r)) if verbose: print("r " + str(r))
self.assertEqual(job.par.usecase, "startjob") self.assertEqual(job.par.usecase, "startjob")
self.assertEqual(job.par.tstime, "2021-08-21_10-02-01") self.assertEqual(job.par.tstime, "2021-08-21_10-02-01")

8
test/test_04config.py

@ -32,21 +32,21 @@ class MyTestCase(unittest.TestCase):
return return
job = test.testtools.getJob() job = test.testtools.getJob()
x = B.SUBJECT_APPS x = B.SUBJECT_APPS
r = utils.config_tool.getConfigPath(P.KEY_BASIC, x) r = utils.config_tool.getConfigPath(x, P.KEY_BASIC)
self.assertIn(os.path.join(T.COMP_PATH, B.SUBJECT_APPS), r) self.assertIn(os.path.join(T.COMP_PATH, B.SUBJECT_APPS), r)
cnttest += 1 cnttest += 1
x = "path" x = "path"
r = utils.config_tool.getConfigPath(P.KEY_TOOL, x) r = utils.config_tool.getConfigPath(x, P.KEY_TOOL)
self.assertIn(os.path.join(T.PROG_PATH, P.VAL_UTIL, P.VAL_CONFIG), r) self.assertIn(os.path.join(T.PROG_PATH, P.VAL_UTIL, P.VAL_CONFIG), r)
cnttest += 1 cnttest += 1
x = "conn" x = "conn"
r = utils.config_tool.getConfigPath(P.KEY_TOOL, x) r = utils.config_tool.getConfigPath(x, P.KEY_TOOL)
self.assertIn(os.path.join(job.conf.getPath(P.ATTR_PATH_ENV)), r) self.assertIn(os.path.join(job.conf.getPath(P.ATTR_PATH_ENV)), r)
cnttest += 1 cnttest += 1
self.assertRaises(Exception, utils.config_tool.getConfigPath, (P.KEY_COMP, "TestX2")) self.assertRaises(Exception, utils.config_tool.getConfigPath, (P.KEY_COMP, "TestX2"))
# self.assertEqual(r, None) # self.assertEqual(r, None)
cnttest += 1 cnttest += 1
r = utils.config_tool.getConfigPath(P.KEY_COMP, "testcrm") r = utils.config_tool.getConfigPath(job, P.KEY_COMP, "testcrm")
self.assertIn(os.path.join(job.conf.getPath(P.ATTR_PATH_COMPONENTS), "testcrm", "CONFIG"), r) self.assertIn(os.path.join(job.conf.getPath(P.ATTR_PATH_COMPONENTS), "testcrm", "CONFIG"), r)
r = utils.config_tool.getConfig(job, P.KEY_TOOL, "path") r = utils.config_tool.getConfig(job, P.KEY_TOOL, "path")
if verbose: print("pattern " + r["pattern"]["log"]) if verbose: print("pattern " + r["pattern"]["log"])

8
test/test_08i18n.py

@ -38,7 +38,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
i18n = utils.i18n_tool.I18n.getInstance() i18n = utils.i18n_tool.I18n.getInstance(job)
self.assertIsNotNone(i18n) self.assertIsNotNone(i18n)
cnttest += 1 cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
@ -52,7 +52,7 @@ class MyTestCase(unittest.TestCase):
return return
job = test.testtools.getJob() job = test.testtools.getJob()
job.conf.confs["language"] = "de" job.conf.confs["language"] = "de"
i18n = utils.i18n_tool.I18n.getInstance() i18n = utils.i18n_tool.I18n.getInstance(job)
res = i18n.getText(f"{EXP_KEY_MISSING=}", job) res = i18n.getText(f"{EXP_KEY_MISSING=}", job)
if verbose: print("RESULT "+res) if verbose: print("RESULT "+res)
self.assertEqual(res, "Schluesselwort fehlt {}") self.assertEqual(res, "Schluesselwort fehlt {}")
@ -66,7 +66,7 @@ class MyTestCase(unittest.TestCase):
self.assertEqual(res, "project") self.assertEqual(res, "project")
cnttest += 1 cnttest += 1
job.conf.confs["language"] = "fr" job.conf.confs["language"] = "fr"
i18n = utils.i18n_tool.I18n.getInstance() i18n = utils.i18n_tool.I18n.getInstance(job)
self.assertRaises(Exception, i18n.getText, (f"{EXP_KEY_MISSING=}", job)) self.assertRaises(Exception, i18n.getText, (f"{EXP_KEY_MISSING=}", job))
cnttest += 1 cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
@ -80,7 +80,7 @@ class MyTestCase(unittest.TestCase):
return return
job = test.testtools.getJob() job = test.testtools.getJob()
job.conf.confs["language"] = "de" job.conf.confs["language"] = "de"
i18n = utils.i18n_tool.I18n.getInstance() i18n = utils.i18n_tool.I18n.getInstance(job)
# i18n.getText("EXP_KEY_MISSING", EXP_KEY_MISSING, job) # i18n.getText("EXP_KEY_MISSING", EXP_KEY_MISSING, job)
res = i18n.getAliasList(f"{EXP_KEY_MISSING=}", job) res = i18n.getAliasList(f"{EXP_KEY_MISSING=}", job)
if verbose: print("RESULT "+str(res)) if verbose: print("RESULT "+str(res))

11
test/test_11component.py

@ -31,7 +31,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
cm = basic.componentHandling.ComponentManager() cm = basic.componentHandling.ComponentManager.getInstance(job)
cm.createComponent("testpoldb", 0, "") cm.createComponent("testpoldb", 0, "")
self.assertIn("testpoldb", cm.comps, "component must be stored") self.assertIn("testpoldb", cm.comps, "component must be stored")
self.assertEqual(len(cm.comps), 1, "component without subcomponents") self.assertEqual(len(cm.comps), 1, "component without subcomponents")
@ -56,7 +56,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
cm = basic.componentHandling.ComponentManager.getInstance("J") cm = basic.componentHandling.ComponentManager.getInstance(job, "J")
componentName = "testcm" componentName = "testcm"
confs = utils.config_tool.getConfig(job, "comp", componentName) confs = utils.config_tool.getConfig(job, "comp", componentName)
conns = utils.conn_tool.getConnections(job, componentName) conns = utils.conn_tool.getConnections(job, componentName)
@ -86,7 +86,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
cm = basic.componentHandling.ComponentManager.getInstance("J") cm = basic.componentHandling.ComponentManager.getInstance(job, "J")
self.assertIsNotNone(cm) self.assertIsNotNone(cm)
self.assertEqual(len(cm.components), 0) self.assertEqual(len(cm.components), 0)
cnttest += 2 cnttest += 2
@ -100,7 +100,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
cm = basic.componentHandling.ComponentManager() cm = basic.componentHandling.ComponentManager.getInstance(job)
cm.createComponent("testcm", 0, "") cm.createComponent("testcm", 0, "")
cm.createComponent("testcrm", 0, "") cm.createComponent("testcrm", 0, "")
prog = "init_testcase" prog = "init_testcase"
@ -120,7 +120,8 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
cm = basic.componentHandling.ComponentManager() print("jobid "+job.jobid)
cm = basic.componentHandling.ComponentManager.getInstance(job)
cm.createComponent("testcm", 0, "") cm.createComponent("testcm", 0, "")
self.assertEqual(len(cm.comps), 6, "6 components inside") self.assertEqual(len(cm.comps), 6, "6 components inside")
comp = cm.getComponent("testprd") comp = cm.getComponent("testprd")

33
test/test_21tdata.py

@ -67,7 +67,7 @@ class MyTestCase(unittest.TestCase):
";;;;;;", ";;;;;;",
"#;;;;;;" "#;;;;;;"
] ]
tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, job) tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, {}, job)
self.assertEqual(0, len(tdata)) self.assertEqual(0, len(tdata))
cnttest += 1 cnttest += 1
if "malformated" in tests: if "malformated" in tests:
@ -104,7 +104,7 @@ class MyTestCase(unittest.TestCase):
"option:description;something;;;;;", "option:description;something;;;;;",
"#;;;;;;" "#;;;;;;"
] ]
tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, job) tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, {}, job)
self.assertEqual(1, len(tdata)) self.assertEqual(1, len(tdata))
print(tdata) print(tdata)
self.assertIn(D.CSV_BLOCK_OPTION, tdata) self.assertIn(D.CSV_BLOCK_OPTION, tdata)
@ -114,7 +114,7 @@ class MyTestCase(unittest.TestCase):
"step:1;testa;1;1;table:_lofts,action:import;;;;;", "step:1;testa;1;1;table:_lofts,action:import;;;;;",
"#;;;;;;" "#;;;;;;"
] ]
tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, job) tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, {}, job)
print(tdata) print(tdata)
self.assertEqual(1, len(tdata)) self.assertEqual(1, len(tdata))
self.assertIn(B.DATA_NODE_STEPS, tdata) self.assertIn(B.DATA_NODE_STEPS, tdata)
@ -131,7 +131,7 @@ class MyTestCase(unittest.TestCase):
"#;;;;;;" "#;;;;;;"
] ]
tdata = {} tdata = {}
tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, job) tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, {}, job)
print(tdata) print(tdata)
self.assertEqual(1, len(tdata)) self.assertEqual(1, len(tdata))
self.assertIn(B.DATA_NODE_STEPS, tdata) self.assertIn(B.DATA_NODE_STEPS, tdata)
@ -144,7 +144,7 @@ class MyTestCase(unittest.TestCase):
"testa:lofts;1;stra;town;12345;usa;4;1;50;house;111;45;8", "testa:lofts;1;stra;town;12345;usa;4;1;50;house;111;45;8",
"#;;;;;;" "#;;;;;;"
] ]
tdata = t.parseCsvSpec(job.m, specLines, B.DATA_NODE_TABLES, job) tdata = t.parseCsvSpec(job.m, specLines, B.DATA_NODE_TABLES, {}, job)
print(tdata) print(tdata)
self.assertEqual(1, len(tdata)) self.assertEqual(1, len(tdata))
self.assertIn(B.DATA_NODE_TABLES, tdata) self.assertIn(B.DATA_NODE_TABLES, tdata)
@ -170,7 +170,7 @@ class MyTestCase(unittest.TestCase):
"testrest:person;1;Brecht;Bert;10.02.98;m", "testrest:person;1;Brecht;Bert;10.02.98;m",
"testrest:person,testcrmdb:person;2;Leon;Donna;28.09.42;f" "testrest:person,testcrmdb:person;2;Leon;Donna;28.09.42;f"
] ]
tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, job) tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_DATA, {}, job)
print(tdata) print(tdata)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
@ -209,7 +209,7 @@ class MyTestCase(unittest.TestCase):
";;;;;;", ";;;;;;",
"#;;;;;;" "#;;;;;;"
] ]
tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_KEYS, job) tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_KEYS, {}, job)
self.assertEqual(0, len(tdata)) self.assertEqual(0, len(tdata))
cnttest += 1 cnttest += 1
if "malformated" in tests: if "malformated" in tests:
@ -227,11 +227,11 @@ class MyTestCase(unittest.TestCase):
";berlin;;;;;", ";berlin;;;;;",
";cairo;;;;;" ";cairo;;;;;"
] ]
tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_KEYS, job) tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_KEYS, {}, job)
print(str(tdata)) print(str(tdata))
self.assertEqual(1, len(tdata)) self.assertEqual(1, len(tdata))
self.assertEqual(1, len(tdata["_tables"])) self.assertEqual(1, len(tdata["_tables"]))
self.assertEqual(3, len(tdata["_tables"]["capital"])) self.assertEqual(4, len(tdata["_tables"]["capital"]))
self.assertEqual(3, len(tdata["_tables"]["capital"]["_keys"])) self.assertEqual(3, len(tdata["_tables"]["capital"]["_keys"]))
cnttest += 4 cnttest += 4
specLines = [ specLines = [
@ -242,13 +242,13 @@ class MyTestCase(unittest.TestCase):
";greece;;;;;", ";greece;;;;;",
";germany;;;;;" ";germany;;;;;"
] ]
tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_KEYS, job) tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_KEYS, {}, job)
#tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_TREE) #tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_TREE)
print(str(tdata)) print(str(tdata))
self.assertEqual(1, len(tdata)) self.assertEqual(1, len(tdata))
self.assertIn("capital", tdata["_tables"]) self.assertIn("capital", tdata["_tables"])
self.assertEqual(2, len(tdata["_tables"])) self.assertEqual(2, len(tdata["_tables"]))
self.assertEqual(3, len(tdata["_tables"]["country"])) self.assertEqual(4, len(tdata["_tables"]["country"]))
self.assertEqual(2, len(tdata["_tables"]["country"]["_keys"])) self.assertEqual(2, len(tdata["_tables"]["country"]["_keys"]))
cnttest += 4 cnttest += 4
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
@ -272,7 +272,7 @@ class MyTestCase(unittest.TestCase):
";city;b;str;;F:1", ";city;b;str;;F:1",
"#;;;;;;" "#;;;;;;"
] ]
tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_CONF, job) tdata = t.parseCsvSpec(job.m, specLines, D.CSV_SPECTYPE_CONF, {}, job)
print(tdata) print(tdata)
self.assertEqual(1, len(tdata)) self.assertEqual(1, len(tdata))
self.assertNotIn(B.DATA_NODE_TABLES, tdata) self.assertNotIn(B.DATA_NODE_TABLES, tdata)
@ -292,7 +292,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
cm = basic.componentHandling.ComponentManager.getInstance("J") cm = basic.componentHandling.ComponentManager.getInstance(job)
componentName = "testcrmdb" componentName = "testcrmdb"
confs = utils.config_tool.getConfig(job, "comp", componentName) confs = utils.config_tool.getConfig(job, "comp", componentName)
conns = utils.conn_tool.getConnections(job, componentName) conns = utils.conn_tool.getConnections(job, componentName)
@ -303,7 +303,7 @@ class MyTestCase(unittest.TestCase):
"testcrmdb:person;2;Leon;Donna;28.09.42;f", "testcrmdb:person;2;Leon;Donna;28.09.42;f",
"#;;;;;;" "#;;;;;;"
] ]
filename = utils.path_tool.rejoinPath(utils.path_tool.composePath(P.P_TCBASE, comp), "t_person.csv") filename = utils.path_tool.rejoinPath(utils.path_tool.composePath(job, P.P_TCBASE, comp), "t_person.csv")
tdata = t.parseCsv(comp.m, job, filename, fileLines, comp, aliasNode="") tdata = t.parseCsv(comp.m, job, filename, fileLines, comp, aliasNode="")
print(str(tdata)) print(str(tdata))
self.assertIn(B.DATA_NODE_TABLES, tdata) self.assertIn(B.DATA_NODE_TABLES, tdata)
@ -323,7 +323,7 @@ class MyTestCase(unittest.TestCase):
self.assertIn("person", tdata[B.DATA_NODE_TABLES]) self.assertIn("person", tdata[B.DATA_NODE_TABLES])
self.assertEqual(2, len(tdata[B.DATA_NODE_TABLES]["person"][B.DATA_NODE_DATA])) self.assertEqual(2, len(tdata[B.DATA_NODE_TABLES]["person"][B.DATA_NODE_DATA]))
cnttest += 3 cnttest += 3
filename = utils.path_tool.rejoinPath(utils.path_tool.composePath(P.P_TCRESULT, comp), "person.csv") filename = utils.path_tool.rejoinPath(utils.path_tool.composePath(job, P.P_TCRESULT, comp), "person.csv")
fileLines = [ fileLines = [
"_date;27.06.2022", "_date;27.06.2022",
"_count;2", "_count;2",
@ -339,7 +339,8 @@ class MyTestCase(unittest.TestCase):
cnttest += 3 cnttest += 3
text = "" text = ""
for k in tdata[B.DATA_NODE_TABLES]: for k in tdata[B.DATA_NODE_TABLES]:
text += t.buildCsvData(filename, tdata[B.DATA_NODE_TABLES][k], comp, job) print("---------\n"+str(tdata))
text += t.buildCsvData(tdata[B.DATA_NODE_TABLES], k, comp, job)
text += "\n" text += "\n"
print(text) print(text)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)

12
test/test_22compare.py

@ -143,7 +143,8 @@ class MyTestCase(unittest.TestCase):
cnttest = 0 cnttest = 0
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
matching = self.getMatching(job, ) job = test.testtools.getJob()
matching = self.getMatching(job)
utils.match_tool.setMatchkeys(matching, ":database:scheme:table:_data") utils.match_tool.setMatchkeys(matching, ":database:scheme:table:_data")
utils.match_tool.getSimilarity(matching, utils.match_tool.getSimilarity(matching,
tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA][0], tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA][0],
@ -211,9 +212,9 @@ class MyTestCase(unittest.TestCase):
comp.files = { "A": "/home/match/pre.csv", "B": "/home/match/post.csv"} comp.files = { "A": "/home/match/pre.csv", "B": "/home/match/post.csv"}
comp.name = "component" comp.name = "component"
comp.conf = conf comp.conf = conf
cm = basic.componentHandling.ComponentManager() cm = basic.componentHandling.ComponentManager.getInstance(job)
basic.componentHandling.comps["component"] = comp basic.componentHandling.comps["component"] = comp
matching = self.getMatching(job, comp) matching = self.getMatching(job)
comp.name = "component" comp.name = "component"
matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA] matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA]
matching.sideB = tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA] matching.sideB = tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA]
@ -234,7 +235,7 @@ class MyTestCase(unittest.TestCase):
comp = basic.component.Component() comp = basic.component.Component()
comp.files = {"A": "/home/match/per.csv", "B": "/home/match/post.csv"} comp.files = {"A": "/home/match/per.csv", "B": "/home/match/post.csv"}
comp.name = "component" comp.name = "component"
cm = basic.componentHandling.ComponentManager() cm = basic.componentHandling.ComponentManager.getInstance(job)
cm.comps["component"] = comp cm.comps["component"] = comp
# tdata["postReq"] = tdata["preAct"] # tdata["postReq"] = tdata["preAct"]
comp.conf = conf comp.conf = conf
@ -247,10 +248,11 @@ class MyTestCase(unittest.TestCase):
print("\n-------------\n") print("\n-------------\n")
print(matching.difftext) print(matching.difftext)
def getMatching(self, job): def getMatching(self, job, comp=None):
job = test.testtools.getJob() job = test.testtools.getJob()
setattr(job.par, B.PAR_TESTCASE, "TC0001") setattr(job.par, B.PAR_TESTCASE, "TC0001")
setattr(job.par, "tctime", "2022-03-25_19-25-31") setattr(job.par, "tctime", "2022-03-25_19-25-31")
if comp is None:
comp = basic.component.Component() comp = basic.component.Component()
comp.files = { "A": "/home/match/per.csv", "B": "/home/match/post.csv"} comp.files = { "A": "/home/match/per.csv", "B": "/home/match/post.csv"}
comp.name = "component" comp.name = "component"

25
test/test_22report.py → test/test_23report.py

@ -19,9 +19,9 @@ TEST_FUNCTIONS = ["test_21title"]
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------" mymsg = "--------------------------------------------------------------"
def getReport(self): def getReport(self, job):
job = test.testtools.getJob() # job = test.testtools.getJob()
report = utils.report_tool.Report() report = utils.report_tool.Report(job)
archiv = job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV]+"/" archiv = job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV]+"/"
i = 0 i = 0
for m in M.MATCH_TYPES: for m in M.MATCH_TYPES:
@ -55,7 +55,7 @@ class MyTestCase(unittest.TestCase):
#job.par.setParameterArgs(args) #job.par.setParameterArgs(args)
#job.setProgram("test_executer") #job.setProgram("test_executer")
job = test.testtools.getJob() job = test.testtools.getJob()
report = self.getReport() report = self.getReport(job)
i = 0 i = 0
for m in M.MATCH_TYPES: for m in M.MATCH_TYPES:
cssClass = report.getCssClass("TC0001", "comp01", "arte01", m) cssClass = report.getCssClass("TC0001", "comp01", "arte01", m)
@ -89,7 +89,7 @@ class MyTestCase(unittest.TestCase):
job = test.testtools.getJob() job = test.testtools.getJob()
print(" ---------- test_title") print(" ---------- test_title")
setattr(job.par, B.PAR_TESTSUITE, "TST001") setattr(job.par, B.PAR_TESTSUITE, "TST001")
report = self.getReport() report = self.getReport(job)
html = report.getTitle("TC0001", "comp01", "arte01", M.MATCH_POSTCOND) html = report.getTitle("TC0001", "comp01", "arte01", M.MATCH_POSTCOND)
print(html) print(html)
html = report.getTitle("TC0001") html = report.getTitle("TC0001")
@ -97,6 +97,7 @@ class MyTestCase(unittest.TestCase):
self.assertEqual((utils.report_tool.REP_TC in html), True) self.assertEqual((utils.report_tool.REP_TC in html), True)
self.assertEqual(("TC0001" in html), True) self.assertEqual(("TC0001" in html), True)
cnttest += 3 cnttest += 3
setattr(job.par, B.PAR_TESTSUITE, "TST001")
html = report.getTitle() html = report.getTitle()
self.assertEqual((utils.report_tool.REP_TITLE in html), True) self.assertEqual((utils.report_tool.REP_TITLE in html), True)
self.assertEqual((utils.report_tool.REP_TS in html), True) self.assertEqual((utils.report_tool.REP_TS in html), True)
@ -112,7 +113,7 @@ class MyTestCase(unittest.TestCase):
return return
job = test.testtools.getJob() job = test.testtools.getJob()
print(" ---------- test_overview") print(" ---------- test_overview")
report = self.getReport() report = self.getReport(job)
html = report.getOverview("TC0001") html = report.getOverview("TC0001")
print(html) print(html)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
@ -128,13 +129,13 @@ class MyTestCase(unittest.TestCase):
setattr(job.par, "testcase", "TC0001") setattr(job.par, "testcase", "TC0001")
setattr(job.par, "tctime", "2022-03-23_21-23-32") setattr(job.par, "tctime", "2022-03-23_21-23-32")
print(" ---------- test_filename") print(" ---------- test_filename")
cm = basic.componentHandling.ComponentManager() cm = basic.componentHandling.ComponentManager.getInstance(job)
for c in ["comp02"]: for c in ["comp02"]:
comp = basic.component.Component() comp = basic.component.Component()
comp.conf = {} comp.conf = {}
comp.name = c comp.name = c
cm.comps[c] = comp cm.comps[c] = comp
report = self.getReport() report = self.getReport(job)
html = report.getFilepath("TC0001", "comp02", "arte01", M.MATCH_POSTCOND) html = report.getFilepath("TC0001", "comp02", "arte01", M.MATCH_POSTCOND)
print(html) print(html)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
@ -148,14 +149,14 @@ class MyTestCase(unittest.TestCase):
job = test.testtools.getJob() job = test.testtools.getJob()
setattr(job.par, "testcase", "TC0001") setattr(job.par, "testcase", "TC0001")
setattr(job.par, "tctime", "2022-03-23_21-23-32") setattr(job.par, "tctime", "2022-03-23_21-23-32")
cm = basic.componentHandling.ComponentManager() cm = basic.componentHandling.ComponentManager.getInstance(job)
for c in ["comp02"]: for c in ["comp02"]:
comp = basic.component.Component() comp = basic.component.Component()
comp.conf = {} comp.conf = {}
comp.name = c comp.name = c
cm.comps[c] = comp cm.comps[c] = comp
print(" ---------- test_headlines") print(" ---------- test_headlines")
report = self.getReport() report = self.getReport(job)
html = report.getTestcaseHead("TC0001") html = report.getTestcaseHead("TC0001")
print(html) print(html)
html = report.getComponentHead("TC0001", "comp02") html = report.getComponentHead("TC0001", "comp02")
@ -175,8 +176,8 @@ class MyTestCase(unittest.TestCase):
setattr(job.par, "testcases", ["TC0001", "TC0002"]) setattr(job.par, "testcases", ["TC0001", "TC0002"])
setattr(job.par, "tctime", "2022-03-23_21-23-32") setattr(job.par, "tctime", "2022-03-23_21-23-32")
print(" ---------- reportTestcase") print(" ---------- reportTestcase")
report = self.getReport() report = self.getReport(job)
cm = basic.componentHandling.ComponentManager() cm = basic.componentHandling.ComponentManager.getInstance(job)
for compname in ["comp01", "comp02"]: for compname in ["comp01", "comp02"]:
conf = {} conf = {}
comp = basic.component.Component() comp = basic.component.Component()

8
test/test_25map.py

@ -61,7 +61,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
path = utils.config_tool.getConfigPath(P.KEY_TESTCASE, "TC0001", "", job) path = utils.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "")
tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA)
args = {} args = {}
args[B.DATA_NODE_DATA] = tdata args[B.DATA_NODE_DATA] = tdata
@ -111,7 +111,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
path = utils.config_tool.getConfigPath(P.KEY_TESTCASE, "TC0001", "", job) path = utils.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "")
tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA)
condIds = [["1"]] condIds = [["1"]]
args = {} args = {}
@ -129,7 +129,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
path = utils.config_tool.getConfigPath(P.KEY_TESTCASE, "TC0001", "", job) path = utils.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "")
tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA)
condIds = [["1"]] condIds = [["1"]]
args = {} args = {}
@ -175,7 +175,7 @@ class MyTestCase(unittest.TestCase):
comp = test.testtools.getComp(job, "testrest") comp = test.testtools.getComp(job, "testrest")
path = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], "testrest", "mapping-rest.yml") path = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], "testrest", "mapping-rest.yml")
mapping = utils.file_tool.readFileDict(job, path, job.m) mapping = utils.file_tool.readFileDict(job, path, job.m)
path = utils.config_tool.getConfigPath(P.KEY_TESTCASE, "TC0001", "", job) path = utils.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "")
tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA)
res = utils.map_tool.mapTdata(job, mapping, tdata, tdata[B.DATA_NODE_STEPS][1], comp) res = utils.map_tool.mapTdata(job, mapping, tdata, tdata[B.DATA_NODE_STEPS][1], comp)
print(res) print(res)

5
test/test_31db.py

@ -96,8 +96,9 @@ class MyTestCase(unittest.TestCase):
comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+"
sqls = comp.composeSqlClauses(job, "SELECT * FROM lofts") sqls = comp.composeSqlClauses(job, "SELECT * FROM lofts")
print(sqls) print(sqls)
self.assertIn("street", sqls["ALL"]) #assertEqual(("street" in sqls), True) # dummy-comp does not correspond with any comp
self.assertIn("state", sqls["ALL"]) #self.assertIn("street", sqls["ALL"]) #assertEqual(("street" in sqls), True)
#self.assertIn("state", sqls["ALL"])
setattr(job.par, B.PAR_DB_WHERE, "family like !%utz%! and state = !+reg+!") setattr(job.par, B.PAR_DB_WHERE, "family like !%utz%! and state = !+reg+!")
comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+"
sqls = comp.composeSqlClauses(job, "SELECT * FROM lofts") sqls = comp.composeSqlClauses(job, "SELECT * FROM lofts")

8
test/test_32file.py

@ -27,7 +27,7 @@ conf = {}
# here you can select single testfunction for developping the tests # here you can select single testfunction for developping the tests
# "test_toolhandling", "test_parseSql" -> test of components # "test_toolhandling", "test_parseSql" -> test of components
TEST_FUNCTIONS = ["test_11mapTdata"] TEST_FUNCTIONS = ["test_11mapTdata"]
TEST_FUNCTIONS = ["test_05getValue"] # TEST_FUNCTIONS = ["test_11mapTdata"]
verbose = False verbose = False
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
@ -41,12 +41,6 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
comp = test.testtools.getComp(job, "testrest")
path = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], "testrest", "mapping-rest.yml")
mapping = utils.file_tool.readFileDict(job, path, job.m)
path = utils.config_tool.getConfigPath(P.KEY_TESTCASE, "TC0001", "", job)
tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA)
res = utils.file_abstract.mapTdata(job, mapping, tdata, tdata[B.DATA_NODE_STEPS][0], comp)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)

2
test/test_71job.py

@ -143,7 +143,7 @@ class MyTestCase(unittest.TestCase):
print("fertig") print("fertig")
def copyAppData(job, program, tdsource): def copyAppData(job, program, tdsource):
cm = basic.componentHandling.ComponentManager.getInstance("init") cm = basic.componentHandling.ComponentManager.getInstance(job, "init")
print("cm " + str(cm)) print("cm " + str(cm))
cm.initComponents() cm.initComponents()
comps = cm.getComponents(program) comps = cm.getComponents(program)

5
test/testtools.py

@ -12,6 +12,7 @@ DEFAULT_DATA_DIR = T.DATA_PATH + "/tdata"
DEFAULT_ARCHIV_DIR = T.DATA_PATH + "/lauf" DEFAULT_ARCHIV_DIR = T.DATA_PATH + "/lauf"
DEFAULT_TIME = "2022-03-19_12-09-09" DEFAULT_TIME = "2022-03-19_12-09-09"
DEFAULT_MODE = "unit" DEFAULT_MODE = "unit"
DEFAULT_COMP = "testcrmdb"
gran = "" gran = ""
app = "" app = ""
env = "" env = ""
@ -83,8 +84,10 @@ def getJob(pgran="", papp="", penv="", ptstamp="", pmode=""):
return job return job
def getComp(job, componentName): def getComp(job, componentName=""):
comp = basic.component.Component() comp = basic.component.Component()
if len(componentName) < 1:
componentName = DEFAULT_COMP
comp.conf = {} comp.conf = {}
comp.name = componentName comp.name = componentName
confs = utils.config_tool.getConfig(job, "comp", componentName) confs = utils.config_tool.getConfig(job, "comp", componentName)

3
utils/cli_abstract.py

@ -36,7 +36,8 @@ class CliFcts():
def reset_TData(self, job): def reset_TData(self, job):
pass pass
def setComp(self, comp): def setComp(self, job, comp):
self.job = job
self.comp = comp self.comp = comp
def execCommand(self, comp, command): def execCommand(self, comp, command):

8
utils/config_tool.py

@ -24,7 +24,7 @@ import utils.path_const as P
COMP_FILES = [D.DDL_FILENAME] COMP_FILES = [D.DDL_FILENAME]
CONFIG_FORMAT = [D.DFILE_TYPE_YML, D.DFILE_TYPE_JSON, D.DFILE_TYPE_CSV] CONFIG_FORMAT = [D.DFILE_TYPE_YML, D.DFILE_TYPE_JSON, D.DFILE_TYPE_CSV]
def getConfigPath(modul, name, subname="", job=None): def getConfigPath(job, modul, name, subname=""):
""" """
gets the most specified configuration of different sources gets the most specified configuration of different sources
Parameter: Parameter:
@ -143,11 +143,11 @@ def getConfigPath(modul, name, subname="", job=None):
if os.path.exists(pathname): if os.path.exists(pathname):
return pathname return pathname
else: else:
pathname = utils.path_tool.composePath(P.P_TCPARFILE) pathname = utils.path_tool.composePath(job, P.P_TCPARFILE)
job.debug(verify, "7 " + pathname) job.debug(verify, "7 " + pathname)
if os.path.exists(pathname): if os.path.exists(pathname):
return pathname return pathname
pathname = utils.path_tool.composePath(P.P_TSPARFILE) pathname = utils.path_tool.composePath(job, P.P_TSPARFILE)
job.debug(verify, "8 " + pathname) job.debug(verify, "8 " + pathname)
if os.path.exists(pathname): if os.path.exists(pathname):
return pathname return pathname
@ -230,7 +230,7 @@ def getConfig(job, modul, name, subname=""):
verify = job.getDebugLevel("config_tool")-4 verify = job.getDebugLevel("config_tool")-4
msg = None msg = None
if hasattr(job, "m"): msg = job.m if hasattr(job, "m"): msg = job.m
pathname = getConfigPath(modul, name, subname, job) pathname = getConfigPath(job, modul, name, subname)
confs = {} confs = {}
job.debug(verify, "getConfig " + pathname) job.debug(verify, "getConfig " + pathname)
if len(pathname) < 1: if len(pathname) < 1:

1
utils/file_tool.py

@ -8,7 +8,6 @@ import json
import os import os
import os.path import os.path
import re import re
import xmltodict import xmltodict
import yaml import yaml

10
utils/i18n_tool.py

@ -23,17 +23,17 @@ class I18n:
* on demand other csv-files in the path * on demand other csv-files in the path
""" """
def __init__(self): def __init__(self, job):
self.cache = {} self.cache = {}
self.cache = utils.config_tool.getConfig(None, P.KEY_TOOL, "i18n") self.cache = utils.config_tool.getConfig(job, P.KEY_TOOL, "i18n")
I18n.__instance = self I18n.__instance = self
pass pass
@staticmethod @staticmethod
def getInstance(): def getInstance(job):
if I18n.__instance == None: if I18n.__instance == None:
return I18n() return I18n(job)
return I18n.__instance return I18n.__instance
@ -63,7 +63,7 @@ class I18n:
out = self.cache[language][key] out = self.cache[language][key]
elif key in self.cache[DEFAULT_LANGUAGE]: elif key in self.cache[DEFAULT_LANGUAGE]:
out = self.cache[DEFAULT_LANGUAGE][key] out = self.cache[DEFAULT_LANGUAGE][key]
return out return str(out)
def getAliasList(self, key, job): def getAliasList(self, key, job):
out = [] out = []

6
utils/match_tool.py

@ -53,7 +53,7 @@ class Matching():
self.matchtype = match self.matchtype = match
self.mode = M.MATCH[match]["mode"] self.mode = M.MATCH[match]["mode"]
self.setDiffHeader() self.setDiffHeader()
self.report = utils.report_tool.Report.getInstance() self.report = utils.report_tool.Report.getInstance(self.job)
self.resetHits() self.resetHits()
if match == M.MATCH_PRECOND: if match == M.MATCH_PRECOND:
self.preIds = {} # structure db:scheme:table:... self.preIds = {} # structure db:scheme:table:...
@ -419,7 +419,7 @@ def matchArray(matching, sideA, sideB, path):
for x in a: for x in a:
if (x == "_data"): break if (x == "_data"): break
table = x table = x
report = utils.report_tool.Report.getInstance() report = utils.report_tool.Report.getInstance(job)
report.setPaths(getattr(job.par, B.PAR_TESTCASE), matching.comp.name, table, matching.matchtype, report.setPaths(getattr(job.par, B.PAR_TESTCASE), matching.comp.name, table, matching.matchtype,
matching.matchfiles[M.M_SIDE_A], matching.matchfiles[M.M_SIDE_B]) matching.matchfiles[M.M_SIDE_A], matching.matchfiles[M.M_SIDE_B])
# report.setMatchResult("TC0001", "comp01", "arte01", m, "result" + str(i), "<table>" + str(i) + "</table>") # report.setMatchResult("TC0001", "comp01", "arte01", m, "result" + str(i), "<table>" + str(i) + "</table>")
@ -435,7 +435,7 @@ def compareRows(matching, path):
job = matching.job # basic.program.Job.getInstance() job = matching.job # basic.program.Job.getInstance()
verify = int(job.getDebugLevel("match_tool")) - 1 verify = int(job.getDebugLevel("match_tool")) - 1
ddl = matching.getTableDdl(path) ddl = matching.getTableDdl(path)
report = utils.report_tool.Report.getInstance() report = utils.report_tool.Report.getInstance(job)
table = "" table = ""
header = [] header = []
# "<p>Tabelle : "+table+"</p>" # "<p>Tabelle : "+table+"</p>"

16
utils/path_tool.py

@ -51,7 +51,7 @@ def getKeyValue(job, key, comp=None):
""" """
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
verify = job.getDebugLevel(TOOL_NAME)-4 verify = job.getDebugLevel(TOOL_NAME)-4
pt = PathConf.getInstance() pt = PathConf.getInstance(job)
job.debug(verify, "getKeyValue " + key) job.debug(verify, "getKeyValue " + key)
if 'job.par' in key: if 'job.par' in key:
val = job.getParameter(key[8:]) val = job.getParameter(key[8:])
@ -90,7 +90,7 @@ def composePath(job, pathname, comp):
""" """
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
verify = job.getDebugLevel(TOOL_NAME) verify = job.getDebugLevel(TOOL_NAME)
pt = PathConf.getInstance() pt = PathConf.getInstance(job)
job.debug(verify, "composePath " + pathname + " zu " + str(pt) + "mit ") job.debug(verify, "composePath " + pathname + " zu " + str(pt) + "mit ")
job.debug(verify, str(pt.pattern)) job.debug(verify, str(pt.pattern))
if pt.pattern[pathname]: if pt.pattern[pathname]:
@ -187,7 +187,7 @@ def extractPattern(job, pathtyp, comp=None):
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
verify = job.getDebugLevel(TOOL_NAME) verify = job.getDebugLevel(TOOL_NAME)
out = [] out = []
pt = PathConf.getInstance() pt = PathConf.getInstance(job)
pattern = pt.pattern[pathtyp] pattern = pt.pattern[pathtyp]
work = pattern work = pattern
while "{" in work: while "{" in work:
@ -213,7 +213,7 @@ def extractPath(job, pathtyp, path):
:return: :return:
""" """
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
patterlist = extractPattern(pathtyp) patterlist = extractPattern(job, pathtyp)
verbose = False verbose = False
work = path work = path
i = 0 i = 0
@ -270,18 +270,18 @@ class PathConf:
this class contains the structure-informations of the testrelevant directories this class contains the structure-informations of the testrelevant directories
""" """
__instance = None __instance = None
def __init__(self): def __init__(self, job=None):
print('init pathConf') print('init pathConf')
confs = utils.config_tool.getConfig(None, "tool", "path") confs = utils.config_tool.getConfig(job, "tool", "path")
self.pattern = confs["pattern"] self.pattern = confs["pattern"]
print(self.pattern) print(self.pattern)
PathConf.__instance = self PathConf.__instance = self
@staticmethod @staticmethod
def getInstance(): def getInstance(job = None):
#print("PathConf getInstance " + str(PathConf.__instance)) #print("PathConf getInstance " + str(PathConf.__instance))
if (PathConf.__instance is None): if (PathConf.__instance is None):
PathConf() PathConf(job)
#print("PathConf getInstance " + str(PathConf.__instance)) #print("PathConf getInstance " + str(PathConf.__instance))
return PathConf.__instance return PathConf.__instance

28
utils/report_tool.py

@ -40,13 +40,14 @@ TOOL_NAME = "report_tool"
class Report: class Report:
__instance = None __instance = None
__instances = {}
@staticmethod @staticmethod
def getInstance(): def getInstance(job):
if (Report.__instance is not None): if (job.jobid in Report.__instances):
return Report.__instance return Report.__instances[job.jobid]
else: else:
return Report() return Report(job)
def __init__(self, job): def __init__(self, job):
""" """
@ -71,6 +72,7 @@ class Report:
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
self.job = job self.job = job
self.report = {} self.report = {}
Report.__instances[job.jobid] = self
self.report["testcases"] = [] self.report["testcases"] = []
self.testcase = "" self.testcase = ""
self.component = "" self.component = ""
@ -104,10 +106,14 @@ class Report:
if len(matchtype) > 1: if len(matchtype) > 1:
html = "<title>"+M.MATCH[matchtype]["title"]+"</title></head><body><h1>"+M.MATCH[matchtype]["title"]+"</h1>" html = "<title>"+M.MATCH[matchtype]["title"]+"</title></head><body><h1>"+M.MATCH[matchtype]["title"]+"</h1>"
elif len(testcase) > 1: elif len(testcase) > 1:
html = "<title>"+REP_TITLE+" "+REP_TC+" "+testcase+"</title></head><body><h1>"+REP_TITLE+" "+REP_TC+" "+testcase+"</h1>" html = "<title>"+REP_TITLE+" "+REP_TC+" "+testcase+"</title></head>"
else: html += "<body><h1>"+REP_TITLE+" "+REP_TC+" "+testcase+"</h1>"
html = "<title>"+REP_TITLE+" "+REP_TS+" "+getattr(job.par, "usecase")+"</title>" elif hasattr(job.par, B.PAR_TESTSUITE):
html += "</head><body><h1>"+REP_TITLE+" "+REP_TS+" "+getattr(job.par, "usecase")+"</h1>" html = "<title>" + REP_TITLE + " " + REP_TS + " " + getattr(job.par, B.PAR_TESTSUITE) + "</title>"
html += "</head><body><h1>" + REP_TITLE + " " + REP_TS + " " + getattr(job.par, B.PAR_TESTSUITE) + "</h1>"
elif hasattr(job.par, B.PAR_TESTCASE):
html = "<title>" + REP_TITLE + " " + REP_TC + " " + getattr(job.par, B.PAR_TESTCASE) + "</title></head>"
html += "<body><h1>" + REP_TITLE + " " + REP_TC + " " + getattr(job.par, B.PAR_TESTCASE) + "</h1>"
if hasattr(job.par, B.PAR_DESCRIPT): if hasattr(job.par, B.PAR_DESCRIPT):
html += "<p>"+getattr(job.par, B.PAR_DESCRIPT)+"</p>" html += "<p>"+getattr(job.par, B.PAR_DESCRIPT)+"</p>"
return html return html
@ -199,7 +205,7 @@ class Report:
html = "<h3>"+REP_ART+" "+artefact+"</h3><p>" html = "<h3>"+REP_ART+" "+artefact+"</h3><p>"
for match in self.report[testcase][component][artefact]: for match in self.report[testcase][component][artefact]:
cssClass = self.getCssClass(testcase, component, artefact, match) cssClass = self.getCssClass(testcase, component, artefact, match)
path = self.getFilepath(testcase, component, artefact, match) path = self.getFilepath(job, testcase, component, artefact, match)
path = path.replace(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV], os.path.join("..", "..")) path = path.replace(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV], os.path.join("..", ".."))
html += " <a href=\""+path+"\" "+utils.css_tool.getInlineStyle(job, "resultFile", cssClass)+">"+M.MATCH[match]["filename"]+"<a> " html += " <a href=\""+path+"\" "+utils.css_tool.getInlineStyle(job, "resultFile", cssClass)+">"+M.MATCH[match]["filename"]+"<a> "
html += "</p>" html += "</p>"
@ -215,8 +221,8 @@ class Report:
html += "</p>" html += "</p>"
return html return html
def getFilepath(self, testcase, component, artefact, matchtype): def getFilepath(self, job, testcase, component, artefact, matchtype):
cm = basic.componentHandling.ComponentManager.getInstance("init") cm = basic.componentHandling.ComponentManager.getInstance(self.job, "init")
comp = cm.getComponent(component) comp = cm.getComponent(component)
path = os.path.join(utils.path_tool.composePattern(self.job, "{tcresult}", comp), artefact+"_"+M.MATCH[matchtype]["filename"]+".html") path = os.path.join(utils.path_tool.composePattern(self.job, "{tcresult}", comp), artefact+"_"+M.MATCH[matchtype]["filename"]+".html")
return path return path

34
utils/tdata_tool.py

@ -43,10 +43,10 @@ def collectTestdata(gran, testentity, job):
setBlockLists(job) setBlockLists(job)
if gran == B.PAR_TESTCASE: if gran == B.PAR_TESTCASE:
basispath = utils.path_tool.rejoinPath(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_TDATA], testentity) basispath = utils.path_tool.rejoinPath(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_TDATA], testentity)
pathname = utils.config_tool.getConfigPath(P.KEY_TESTCASE, getattr(job.par, B.PAR_TESTCASE), "", job) pathname = utils.config_tool.getConfigPath(job, P.KEY_TESTCASE, getattr(job.par, B.PAR_TESTCASE), "")
if gran == B.PAR_TESTSUITE: if gran == B.PAR_TESTSUITE:
basispath = utils.path_tool.rejoinPath(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_TDATA], testentity) basispath = utils.path_tool.rejoinPath(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_TDATA], testentity)
pathname = utils.config_tool.getConfigPath(P.KEY_TESTSUITE, getattr(job.par, B.PAR_TESTSUITE), "", job) pathname = utils.config_tool.getConfigPath(job, P.KEY_TESTSUITE, getattr(job.par, B.PAR_TESTSUITE), "")
if pathname[-3:] == D.DFILE_TYPE_CSV: if pathname[-3:] == D.DFILE_TYPE_CSV:
tdata = getCsvSpec(job.m, job, pathname, D.CSV_SPECTYPE_DATA) tdata = getCsvSpec(job.m, job, pathname, D.CSV_SPECTYPE_DATA)
else: else:
@ -90,7 +90,7 @@ def collectTestdata(gran, testentity, job):
def setBlockLists(job): def setBlockLists(job):
for block in D.LIST_BLOCK_CONST + D.LIST_ATTR_CONST + D.LIST_DFNAME_CONST: for block in D.LIST_BLOCK_CONST + D.LIST_ATTR_CONST + D.LIST_DFNAME_CONST:
list = utils.i18n_tool.I18n.getInstance().getAliasList(block+"='"+eval("D."+block)+"'", job) list = utils.i18n_tool.I18n.getInstance(job).getAliasList(block+"='"+eval("D."+block)+"'", job)
#list.append(eval("D."+block)) #list.append(eval("D."+block))
list_blocks[eval("D." + block)] = [] list_blocks[eval("D." + block)] = []
for x in list: for x in list:
@ -374,12 +374,12 @@ def writeCsvData(filename, tdata, comp, job):
text = "" text = ""
if B.DATA_NODE_TABLES in tdata: if B.DATA_NODE_TABLES in tdata:
for k in tdata[B.DATA_NODE_TABLES]: for k in tdata[B.DATA_NODE_TABLES]:
text += buildCsvData(tdata[B.DATA_NODE_TABLES][k], k, job) text += buildCsvData(tdata, k, comp, job)
text += "\n" text += "\n"
utils.file_tool.writeFileText(comp.m, job, filename, text) utils.file_tool.writeFileText(comp.m, job, filename, text)
def buildCsvData(tdata, table, job=None): def buildCsvData(tdata, tableName, comp, job=None):
""" """
writes the testdata into a csv-file for documentation of the test-run writes the testdata into a csv-file for documentation of the test-run
:param teststatus: :param teststatus:
@ -391,19 +391,27 @@ def buildCsvData(tdata, table, job=None):
for k in [D.DATA_ATTR_DATE, D.DATA_ATTR_COUNT]: for k in [D.DATA_ATTR_DATE, D.DATA_ATTR_COUNT]:
if k in tdata: if k in tdata:
text += k+";"+str(tdata[k])+"\n" text += k+";"+str(tdata[k])+"\n"
header = utils.i18n_tool.I18n.getInstance().getText(f"{B.DATA_NODE_TABLES=}", job)+":"+table x0 = "-------"+str(f"{B.DATA_NODE_TABLES=}")
for f in tdata[B.DATA_NODE_HEADER]: x1 = "-------"+str(tableName)
x2 = str(utils.i18n_tool.I18n.getInstance(job).getText(f"{B.DATA_NODE_TABLES=}", job))
print(x0+" "+x1+" "+x2)
if tableName in tdata:
actdata = tdata[tableName]
else:
actdata = tdata
header = str(utils.i18n_tool.I18n.getInstance(job).getText(f"{B.DATA_NODE_TABLES=}", job)) +":" + tableName
for f in actdata[B.DATA_NODE_HEADER]:
header += D.CSV_DELIMITER+f header += D.CSV_DELIMITER+f
text += header + "\n" text += header + "\n"
i = 0 i = 0
for r in tdata[B.DATA_NODE_DATA]: for r in actdata[B.DATA_NODE_DATA]:
row = "" row = ""
if B.ATTR_DATA_COMP in r: if B.ATTR_DATA_COMP in r:
for k in r[B.ATTR_DATA_COMP]: for k in r[B.ATTR_DATA_COMP]:
row += ","+k+":"+r[B.ATTR_DATA_COMP][k] row += ","+k+":"+r[B.ATTR_DATA_COMP][k]
row = row[1:] row = row[1:]
i += 1 i += 1
for f in tdata[B.DATA_NODE_HEADER]: for f in actdata[B.DATA_NODE_HEADER]:
if f in r: if f in r:
row += D.CSV_DELIMITER+str(r[f]) row += D.CSV_DELIMITER+str(r[f])
else: else:
@ -417,25 +425,25 @@ def buildCsvSpec(tdata, job=None):
text = "" text = ""
if D.CSV_BLOCK_IMPORT in tdata: if D.CSV_BLOCK_IMPORT in tdata:
for k in tdata[D.CSV_BLOCK_HEAD]: for k in tdata[D.CSV_BLOCK_HEAD]:
text += utils.i18n_tool.I18n.getInstance().getText(f"{D.CSV_BLOCK_HEAD=}", job) text += utils.i18n_tool.I18n.getInstance(job).getText(f"{D.CSV_BLOCK_HEAD=}", job)
text += ":"+k+D.CSV_DELIMITER+tdata[D.CSV_BLOCK_HEAD][k]+"\n" text += ":"+k+D.CSV_DELIMITER+tdata[D.CSV_BLOCK_HEAD][k]+"\n"
text += "# option:key ;values;..;;;;\n" text += "# option:key ;values;..;;;;\n"
if D.CSV_BLOCK_OPTION in tdata: if D.CSV_BLOCK_OPTION in tdata:
for k in tdata[D.CSV_BLOCK_OPTION]: for k in tdata[D.CSV_BLOCK_OPTION]:
text += utils.i18n_tool.I18n.getInstance().getText(f"{D.CSV_BLOCK_OPTION=}", job) text += utils.i18n_tool.I18n.getInstance(job).getText(f"{D.CSV_BLOCK_OPTION=}", job)
text += ":" + k + D.CSV_DELIMITER + getHeadArgs(tdata[D.CSV_BLOCK_OPTION][k], job)+"\n" text += ":" + k + D.CSV_DELIMITER + getHeadArgs(tdata[D.CSV_BLOCK_OPTION][k], job)+"\n"
text += "#;;;;;;\n" text += "#;;;;;;\n"
if D.CSV_BLOCK_STEP in tdata: if D.CSV_BLOCK_STEP in tdata:
text += basic.step.getStepHeader(job) text += basic.step.getStepHeader(job)
i = 1 i = 1
for step in tdata[D.CSV_BLOCK_STEP]: for step in tdata[D.CSV_BLOCK_STEP]:
text += utils.i18n_tool.I18n.getInstance().getText(f"{D.CSV_BLOCK_STEP=}", job) + ":" + str(i) text += utils.i18n_tool.I18n.getInstance(job).getText(f"{D.CSV_BLOCK_STEP=}", job) + ":" + str(i)
text += D.CSV_DELIMITER + step.getStepText(job) text += D.CSV_DELIMITER + step.getStepText(job)
i += 1 i += 1
text += "#;;;;;;\n" text += "#;;;;;;\n"
if D.CSV_BLOCK_TABLES in tdata: if D.CSV_BLOCK_TABLES in tdata:
for k in tdata[D.CSV_BLOCK_TABLES]: for k in tdata[D.CSV_BLOCK_TABLES]:
text += buildCsvData(tdata[D.CSV_BLOCK_TABLES][k], k, job) text += buildCsvData(tdata, k, None, job)
text += "#;;;;;;\n" text += "#;;;;;;\n"
return text return text

Loading…
Cancel
Save