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.
 
 
 

162 lines
7.0 KiB

import unittest
import os
import basic.program
import basic.program
import components.component
from basic.componentHandling import ComponentManager
import init_testcase
import test_executer
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
class MyTestCase(unittest.TestCase):
def getReport(self):
job = basic.program.Job.getInstance()
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_cssClass(self):
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")
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))
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")
def test_title(self):
job = basic.program.Job.getInstance()
print(" ---------- test_title")
setattr(job.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)
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)
def test_overview(self):
job = basic.program.Job.getInstance()
print(" ---------- test_overview")
report = self.getReport()
html = report.getOverview("TC0001")
print(html)
def test_filename(self):
job = basic.program.Job.getInstance()
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 = components.component.Component()
comp.conf = {}
comp.name = c
basic.componentHandling.comps[c] = comp
report = self.getReport()
html = report.getFilepath("TC0001", "comp02", "arte01", M.MATCH_POSTCOND)
print(html)
def test_headlines(self):
job = basic.program.Job.getInstance()
setattr(job.par, "testcase", "TC0001")
setattr(job.par, "tctime", "2022-03-23_21-23-32")
cm = basic.componentHandling.ComponentManager()
for c in ["comp02"]:
comp = components.component.Component()
comp.conf = {}
comp.name = c
basic.componentHandling.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)
def xtest_reportS(self):
job = basic.program.Job.getInstance()
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 = components.component.Component()
comp.files = { "A": "/home/match/pre.csv", "B": "/home/match/post.csv"}
comp.name = compname
comp.conf = conf
basic.componentHandling.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)
print("<<---------------------------------- TST001")
if __name__ == '__main__':
unittest.main()
# report.setPaths("TC0001", "comp01", "arte01", m, archiv+"path0111"+str(i), archiv+"path0111"+str(i)+"02")