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.
 
 
 

210 lines
8.8 KiB

import unittest
import inspect
import test.testtools
import basic.program
import basic.component
from basic.componentHandling import ComponentManager
import test.constants
import utils.report_tool
import utils.match_tool
import utils.match_const as M
import basic.constants as B
HOME_PATH = test.constants.HOME_PATH
DATA_PATH = test.constants.DATA_PATH
TEST_FUNCTIONS = ["test_20cssClass", "test_21title", "test_22overview", "test_23filename",
"test_24headlines", "test_30reportS"]
TEST_FUNCTIONS = ["test_21title"]
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def getReport(self):
job = test.testtools.getJob()
report = utils.report_tool.Report()
archiv = job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV]+"/"
i = 0
for m in M.MATCH_TYPES:
report.setPaths("TC0001", "comp01", "arte01", m, archiv+"path0111"+str(i), archiv+"path0111"+str(i)+"02")
report.setPaths("TC0001", "comp01", "arte02", m, archiv+"path0112"+str(i)+"", archiv+"path0112"+str(i)+"02")
report.setPaths("TC0001", "comp02", "arte01", m, archiv+"path0121"+str(i)+"", archiv+"path0121"+str(i)+"02")
report.setPaths("TC0002", "comp01", "arte01", m, archiv+"path0211"+str(i)+"", archiv+"path0211"+str(i)+"02")
report.setPaths("TC0002", "comp02", "arte01", m, archiv+"path0221"+str(i)+"", archiv+"path0221"+str(i)+"02")
report.setMatchResult("TC0001", "comp01", "arte01", m, "result" + str(i), "<table>" + str(i) + "</table>")
report.setMatchResult("TC0001", "comp01", "arte02", m, "result" + str(i), "<table>" + str(i) + "</table>")
report.setMatchResult("TC0001", "comp02", "arte01", m, "result" + str(1), "<table>" + str(i) + "</table>")
report.setMatchResult("TC0002", "comp01", "arte01", m, "result" + str(1), "<table>" + str(i) + "</table>")
report.setMatchResult("TC0002", "comp02", "arte01", m, "result" + str(i), "<table>" + str(i) + "</table>")
i += 1
if i > 4:
i = 0
return report
def test_20cssClass(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
#job = basic.program.Job("unit")
#args = { "application": "TEST", "environment": "ENV01", "modus": "unit", "tstime": "2022-03-19_12-09-09",
# "tsdir": '/home/ulrich/6_Projekte/Programme/datest/test/conf/lauf/testlauf/TST001_2022-03-19_12-09-09',
# "step": 2 }
## "usecase": "TST001", "tstime": "2022-03-17_17-28"}
#job.par.setParameterArgs(args)
#job.setProgram("test_executer")
job = test.testtools.getJob()
report = self.getReport()
i = 0
for m in M.MATCH_TYPES:
cssClass = report.getCssClass("TC0001", "comp01", "arte01", m)
print(m + " test0111 " + cssClass)
self.assertEqual(cssClass, "result"+str(i))
cnttest += 1
i += 1
if i > 4:
i = 0
cssClass = report.getCssClass("TC0002", "comp01", "arte01", m)
print(m + " test0121 " + cssClass)
cssClass = report.getCssClass("TC0001", "comp01", "arte02")
self.assertEqual(cssClass, "result4")
print("test0112 "+cssClass)
cssClass = report.getCssClass("TC0001", "comp02", "arte01")
print("test0121 "+cssClass)
self.assertEqual(cssClass, "result1")
cssClass = report.getCssClass("TC0002", "comp01")
self.assertEqual(cssClass, "result1")
cssClass = report.getCssClass("TC0002")
self.assertEqual(cssClass, "result4")
cnttest += 4
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_21title(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
print(" ---------- test_title")
setattr(job.par, B.PAR_TESTSUITE, "TST001")
report = self.getReport()
html = report.getTitle("TC0001", "comp01", "arte01", M.MATCH_POSTCOND)
print(html)
html = report.getTitle("TC0001")
self.assertEqual((utils.report_tool.REP_TITLE in html), True)
self.assertEqual((utils.report_tool.REP_TC in html), True)
self.assertEqual(("TC0001" in html), True)
cnttest += 3
html = report.getTitle()
self.assertEqual((utils.report_tool.REP_TITLE in html), True)
self.assertEqual((utils.report_tool.REP_TS in html), True)
self.assertEqual(("TST001" in html), True)
cnttest += 3
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_22overview(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
print(" ---------- test_overview")
report = self.getReport()
html = report.getOverview("TC0001")
print(html)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_23filename(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
#job = basic.program.Job.getInstance()
job = test.testtools.getJob()
setattr(job.par, "testcase", "TC0001")
setattr(job.par, "tctime", "2022-03-23_21-23-32")
print(" ---------- test_filename")
cm = basic.componentHandling.ComponentManager()
for c in ["comp02"]:
comp = basic.component.Component()
comp.conf = {}
comp.name = c
cm.comps[c] = comp
report = self.getReport()
html = report.getFilepath("TC0001", "comp02", "arte01", M.MATCH_POSTCOND)
print(html)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_24headlines(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
setattr(job.par, "testcase", "TC0001")
setattr(job.par, "tctime", "2022-03-23_21-23-32")
cm = basic.componentHandling.ComponentManager()
for c in ["comp02"]:
comp = basic.component.Component()
comp.conf = {}
comp.name = c
cm.comps[c] = comp
print(" ---------- test_headlines")
report = self.getReport()
html = report.getTestcaseHead("TC0001")
print(html)
html = report.getComponentHead("TC0001", "comp02")
print(html)
html = report.getArtefactBlock("TC0001", "comp02", "arte01")
print(html)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_30reportS(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
setattr(job.par, "testcase", "TC0001")
setattr(job.par, "testcases", ["TC0001", "TC0002"])
setattr(job.par, "tctime", "2022-03-23_21-23-32")
print(" ---------- reportTestcase")
report = self.getReport()
cm = basic.componentHandling.ComponentManager()
for compname in ["comp01", "comp02"]:
conf = {}
comp = basic.component.Component()
comp.files = { "A": "/home/match/pre.csv", "B": "/home/match/post.csv"}
comp.name = compname
comp.conf = conf
cm.comps[compname] = comp
html_1 = report.reportTestcase("TC0001")
print(html_1)
print("<<---------------------------------- TC0001")
report.extractTestcase("TC0001", html_1)
setattr(job.par, "testcase", "TC0002")
html_2 = report.reportTestcase("TC0002")
print(html_2)
print("<<---------------------------------- TC0002")
report.extractTestcase("TC0002", html_2)
# setattr(job.par, B.PAR_TESTCASES, ["TST001"])
setattr(job.par, B.PAR_TESTCASES, ["TC0001", "TC0002"])
#html = report.reportTestsuite()
#print(html)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
print("<<---------------------------------- TST001")
def test_zzz(self):
print(MyTestCase.mymsg)
if __name__ == '__main__':
unittest.main()
# report.setPaths("TC0001", "comp01", "arte01", m, archiv+"path0111"+str(i), archiv+"path0111"+str(i)+"02")