Browse Source

matching and reports

master
Ulrich Carmesin 2 years ago
parent
commit
4768cfd231
  1. 14
      components/testexec.py
  2. 38
      test/test_compare.py
  3. 3
      test/test_tdata.py
  4. 122
      utils/match_tool.py

14
components/testexec.py

@ -38,6 +38,7 @@ import components.component
import basic.componentHandling import basic.componentHandling
import utils.db_abstract import utils.db_abstract
import utils.path_tool import utils.path_tool
import utils.file_tool
import utils.match_tool import utils.match_tool
import utils.tdata_tool import utils.tdata_tool
import basic.constants as B import basic.constants as B
@ -259,7 +260,7 @@ class Testexecuter():
verify = job.getDebugLevel(self.name) verify = job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name)) self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name))
def compare_results(self, granularity): def compare_results(self, report):
""" """
to compare the actual result with the target result has three steps: to compare the actual result with the target result has three steps:
1 matching each element so you get a comparable pair 1 matching each element so you get a comparable pair
@ -285,16 +286,16 @@ class Testexecuter():
comp = cm.getComponent(a[0]) comp = cm.getComponent(a[0])
else: else:
comp = self comp = self
path = os.path.join(utils.path_tool.composePatttern( path = os.path.join(utils.path_tool.composePattern(
"{"+utils.match_tool.MATCH[utils.match_tool.MATCH_SIDE_POSTACTUAL]["filepattern"]+"}", comp), a[1]+".csv") "{"+utils.match_tool.MATCH[utils.match_tool.MATCH_SIDE_POSTACTUAL]["filepattern"]+"}", comp), a[1]+".csv")
pass pass
elif side == utils.match_tool.MATCH_SIDE_TESTCASE: elif side == utils.match_tool.MATCH_SIDE_TESTCASE:
if hasattr(job.par, "testcase_example"): if hasattr(job.par, "testcase_example"):
path = os.path.join(utils.path_tool.composePatttern( path = os.path.join(utils.path_tool.composePattern(
"{"+utils.match_tool.MATCH[utils.match_tool.MATCH_SIDE_POSTEXPECT]["filepattern"]+"}", self), t+".csv") "{"+utils.match_tool.MATCH[utils.match_tool.MATCH_SIDE_POSTEXPECT]["filepattern"]+"}", self), t+".csv")
path.replace(getattr(job.par, "testcase"), getattr(job.par, "testcase_example")) path.replace(getattr(job.par, "testcase"), getattr(job.par, "testcase_example"))
else: else:
path = os.path.join(utils.path_tool.composePatttern("{"+utils.match_tool.MATCH[side]["filepattern"]+"}", self), t+".csv") path = os.path.join(utils.path_tool.composePattern("{" + utils.match_tool.MATCH[side]["filepattern"] + "}", self), t + ".csv")
filedata = utils.tdata_tool.readCsv(self.m, path, self) filedata = utils.tdata_tool.readCsv(self.m, path, self)
data[side] = utils.match_tool.MATCH[side] data[side] = utils.match_tool.MATCH[side]
data[side]["path"] = path data[side]["path"] = path
@ -302,7 +303,12 @@ class Testexecuter():
# execute the matches # execute the matches
for type in utils.match_tool.MATCH_TYPES: for type in utils.match_tool.MATCH_TYPES:
matching.setData(data, type) matching.setData(data, type)
report.setPaths(job.par.testcase, self.name, t, type, matching.matchfiles["A"], matching.matchfiles["B"])
text = utils.match_tool.matchTree(matching) text = utils.match_tool.matchTree(matching)
report.setMatchResult(job.par.testcase, self.name, t, type, matching.cssClass, matching.diffText)
path = os.path.join(utils.path_tool.composePattern("{tcresult}", self),
t+"_"+utils.match_tool.MATCH[type]["filename"]+".html")
utils.file_tool.writeFileText(self.m, path, text)
# write text # write text
pass pass
pass pass

38
test/test_compare.py

@ -1,5 +1,7 @@
import json import json
import unittest import unittest
import basic
from basic.program import Job from basic.program import Job
import utils.match_tool import utils.match_tool
import utils.match_tool as M import utils.match_tool as M
@ -7,7 +9,7 @@ import components.component
tdata = { tdata = {
M.MATCH_SIDE_POSTEXPECT: { M.MATCH_SIDE_POSTEXPECT: {
"path": "", "path": "/home/match/postexpect.csv",
"data": { "data": {
"database": { "database": {
"scheme": { "scheme": {
@ -19,7 +21,7 @@ tdata = {
} }
}, },
M.MATCH_SIDE_PREACTUAL: { M.MATCH_SIDE_PREACTUAL: {
"path": "", "path": "/home/match/peract.csv",
"data": { "data": {
"database": { "database": {
"scheme": { "scheme": {
@ -36,7 +38,7 @@ tdata = {
} }
}, },
M.MATCH_SIDE_POSTACTUAL: { M.MATCH_SIDE_POSTACTUAL: {
"path": "", "path": "/home/match/postact.csv",
"data": { "data": {
"database": { "database": {
"scheme": { "scheme": {
@ -82,16 +84,19 @@ class MyTestCase(unittest.TestCase):
def test_matchstart(self): def test_matchstart(self):
job = Job("unit") job = Job("unit")
setattr(job.par, "testcase", "TC0001")
comp = components.component.Component() comp = components.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.conf = conf comp.conf = conf
comp.name = "component"
matching = utils.match_tool.Matching(comp) matching = utils.match_tool.Matching(comp)
matching.setData(tdata, utils.match_tool.MATCH_SUCCESS) matching.setData(tdata, utils.match_tool.MATCH_SUCCESS)
print(matching.htmltext) print(matching.htmltext)
def xtest_hitmanage(self): def test_hitmanage(self):
comp = components.component.Component() comp = components.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.conf = conf comp.conf = conf
matching = utils.match_tool.Matching(comp) matching = utils.match_tool.Matching(comp)
matching.linksA = { "a0001": "null", "a0002": "null", "a0003": "null", "a0004": "null"} matching.linksA = { "a0001": "null", "a0002": "null", "a0003": "null", "a0004": "null"}
@ -110,9 +115,11 @@ class MyTestCase(unittest.TestCase):
tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"][0], tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"][0],
tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"][0],1) tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"][0],1)
def xtest_bestfit(self): def test_bestfit(self):
job = Job("unit") job = Job("unit")
setattr(job.par, "testcase", "TC0001")
comp = components.component.Component() comp = components.component.Component()
comp.name = "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.conf = conf comp.conf = conf
matching = utils.match_tool.Matching(comp) matching = utils.match_tool.Matching(comp)
@ -127,10 +134,12 @@ class MyTestCase(unittest.TestCase):
print(json.dumps(matching.linksB)) print(json.dumps(matching.linksB))
print(json.dumps(matching.nomatch)) print(json.dumps(matching.nomatch))
def xtest_compareRow(self): def test_compareRow(self):
job = Job("unit") job = Job("unit")
setattr(job.par, "testcase", "TC0001")
comp = components.component.Component() comp = components.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.conf = conf comp.conf = conf
matching = self.getMatching() matching = self.getMatching()
matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"] matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"]
@ -145,12 +154,16 @@ class MyTestCase(unittest.TestCase):
tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"][i]) tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"][i])
print(text) print(text)
def xtest_compareRows(self): def test_compareRows(self):
job = Job("unit") job = Job("unit")
comp = components.component.Component() comp = components.component.Component()
comp.files = { "A": "/home/match/per.csv", "B": "/home/match/post.csv"} comp.files = { "A": "/home/match/pre.csv", "B": "/home/match/post.csv"}
comp.name = "component"
comp.conf = conf comp.conf = conf
cm = basic.componentHandling.ComponentManager()
basic.componentHandling.comps["component"] = comp
matching = self.getMatching() matching = self.getMatching()
comp.name = "component"
matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"] matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"]
matching.sideB = tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"] matching.sideB = tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"]
linksA = {"a0001": "b0001", "a0002": "b0002" } linksA = {"a0001": "b0001", "a0002": "b0002" }
@ -160,11 +173,17 @@ class MyTestCase(unittest.TestCase):
def test_match(self): def test_match(self):
job = Job("unit") job = Job("unit")
setattr(job.par, "testcase", "TC0001")
setattr(job.par, "tctime", "2022-03-25_19-25-31")
comp = components.component.Component() comp = components.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"
cm = basic.componentHandling.ComponentManager()
basic.componentHandling.comps["component"] = comp
# tdata["postReq"] = tdata["preAct"] # tdata["postReq"] = tdata["preAct"]
comp.conf = conf comp.conf = conf
matching = utils.match_tool.Matching(comp) matching = utils.match_tool.Matching(comp)
matching.htmltext = ""
matching.setData(tdata, utils.match_tool.MATCH_POSTCOND) matching.setData(tdata, utils.match_tool.MATCH_POSTCOND)
text = utils.match_tool.matchTree(matching) text = utils.match_tool.matchTree(matching)
print("\n-------------\n") print("\n-------------\n")
@ -174,8 +193,11 @@ class MyTestCase(unittest.TestCase):
def getMatching(self): def getMatching(self):
job = Job("unit") job = Job("unit")
setattr(job.par, "testcase", "TC0001")
setattr(job.par, "tctime", "2022-03-25_19-25-31")
comp = components.component.Component() comp = components.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.conf = conf comp.conf = conf
matching = utils.match_tool.Matching(comp) matching = utils.match_tool.Matching(comp)
matching.setData(tdata, M.MATCH_SUCCESS) matching.setData(tdata, M.MATCH_SUCCESS)

3
test/test_tdata.py

@ -1,6 +1,7 @@
import unittest import unittest
import utils.tdata_tool as t import utils.tdata_tool as t
import basic.program import basic.program
import os
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
def runTest(self): def runTest(self):
@ -28,7 +29,7 @@ class MyTestCase(unittest.TestCase):
"tdtyp": "csv", "tdsrc": "TC0001", "tdname": "testspec", "tdtyp": "csv", "tdsrc": "TC0001", "tdname": "testspec",
"modus": "unit"} "modus": "unit"}
job.par.setParameterArgs(args) job.par.setParameterArgs(args)
filename = str(job.conf.confs["paths"]["testdata"]) + "/" + getattr(job.par, "tdsrc") + "/" + getattr(job.par, "tdname") + ".csv" filename = os.path.join(job.conf.confs["paths"]["testdata"], getattr(job.par, "tdsrc"), getattr(job.par, "tdname") + ".csv")
tdata = t.getCsvSpec(job.m, filename, "data") tdata = t.getCsvSpec(job.m, filename, "data")
print("111") print("111")
print(tdata) print(tdata)

122
utils/match_tool.py

@ -25,35 +25,35 @@ MATCH_SIDE_POSTEXPECT = "postexpect"
MATCH_DICT_POSTEXPECT = { MATCH_DICT_POSTEXPECT = {
"short": "SN", "short": "SN",
"long": "Soll-Nachher", "long": "Soll-Nachher",
"filepattern": "rsprecond" "filepattern": "rspostcond"
} }
MATCH_SIDE_PREACTUAL = "preactual" MATCH_SIDE_PREACTUAL = "preactual"
""" it implies the precondition of the actual execution """ """ it implies the precondition of the actual execution """
MATCH_DICT_PREACTUAL = { MATCH_DICT_PREACTUAL = {
"short": "IV", "short": "IV",
"long": "Ist-Vorher", "long": "Ist-Vorher",
"filepattern": "rsprecond" "filepattern": "tcprecond"
} }
MATCH_SIDE_POSTACTUAL = "postactual" MATCH_SIDE_POSTACTUAL = "postactual"
""" it implies the postondition of the actual execution - it is the result """ """ it implies the postondition of the actual execution - it is the result """
MATCH_DICT_POSTACTUAL = { MATCH_DICT_POSTACTUAL = {
"short": "IN", "short": "IN",
"long": "Ist-Nachher", "long": "Ist-Nachher",
"filepattern": "rsprecond" "filepattern": "tcpostcond"
} }
MATCH_SIDE_PRESTEP = "prestep" MATCH_SIDE_PRESTEP = "preside"
""" it implies the postcondition of a preceding step of the actual execution - the preceding step must be configured in the component""" """ it implies the postcondition of a preceding step of the actual execution - the preceding step must be configured in the component"""
MATCH_DICT_PRESTEP = { MATCH_DICT_PRESTEP = {
"short": "VS", "short": "VS",
"long": "Vorhergehender Schritt (Nachher)", "long": "Vorhergehender Schritt (Nachher)",
"filepattern": "rsprecond" "filepattern": "rspostcond"
} }
MATCH_SIDE_TESTCASE = "testexample" MATCH_SIDE_TESTCASE = "testexample"
""" it implies the postcondition of an exemplary testcase - the exemplary testcase must be parametrized """ """ it implies the postcondition of an exemplary testcase - the exemplary testcase must be parametrized """
MATCH_DICT_TESTCASE = { MATCH_DICT_TESTCASE = {
"short": "VT", "short": "VT",
"long": "Vergleichstestfall (Nachher)", "long": "Vergleichstestfall (Nachher)",
"filepattern": "rsprecond" "filepattern": "rspostcond"
} }
MATCH_SIDES = [MATCH_SIDE_PREEXPECT, MATCH_SIDE_POSTEXPECT, MATCH_SIDE_PREACTUAL, MATCH_SIDE_POSTACTUAL, MATCH_SIDE_PRESTEP, MATCH_SIDE_TESTCASE] MATCH_SIDES = [MATCH_SIDE_PREEXPECT, MATCH_SIDE_POSTEXPECT, MATCH_SIDE_PREACTUAL, MATCH_SIDE_POSTACTUAL, MATCH_SIDE_PRESTEP, MATCH_SIDE_TESTCASE]
@ -78,10 +78,6 @@ MATCH = {
MATCH_PRECOND: { MATCH_PRECOND: {
"A": MATCH_SIDE_PREEXPECT, "A": MATCH_SIDE_PREEXPECT,
"B": MATCH_SIDE_PREACTUAL, "B": MATCH_SIDE_PREACTUAL,
"shortA": "SV",
"shortB": "IV",
"longA": "Soll-Vorher",
"longB": "Ist-Vorher",
"mode": "info", "mode": "info",
"filename": "01_Vorbedingungen", "filename": "01_Vorbedingungen",
"title": "Pruefung Vorbedingung (Soll-Vorher - Ist-Vorher)" "title": "Pruefung Vorbedingung (Soll-Vorher - Ist-Vorher)"
@ -89,10 +85,6 @@ MATCH = {
MATCH_POSTCOND: { MATCH_POSTCOND: {
"A": MATCH_SIDE_POSTEXPECT, "A": MATCH_SIDE_POSTEXPECT,
"B": MATCH_SIDE_POSTACTUAL, "B": MATCH_SIDE_POSTACTUAL,
"shortA": "SN",
"shortB": "IN",
"longA": "Soll-Nachher",
"longB": "Ist-Nachher",
"mode": "hard", "mode": "hard",
"filename": "00_Fachabgleich", "filename": "00_Fachabgleich",
"title": "Fachliche Auswertung (Soll-Nachher - Ist-Nachher)" "title": "Fachliche Auswertung (Soll-Nachher - Ist-Nachher)"
@ -100,10 +92,6 @@ MATCH = {
MATCH_SUCCESS: { MATCH_SUCCESS: {
"A": MATCH_SIDE_PREACTUAL, "A": MATCH_SIDE_PREACTUAL,
"B": MATCH_SIDE_POSTACTUAL, "B": MATCH_SIDE_POSTACTUAL,
"shortA": "IV",
"shortB": "IN",
"longA": "Ist-Vorher",
"longB": "Ist-Nachher",
"mode": "action", "mode": "action",
"filename": "04_Ablauf", "filename": "04_Ablauf",
"title": "Ablauf-Differenz (Ist-Vorher - Ist-Nachher)" "title": "Ablauf-Differenz (Ist-Vorher - Ist-Nachher)"
@ -111,10 +99,6 @@ MATCH = {
MATCH_PRESTEP: { MATCH_PRESTEP: {
"A": MATCH_SIDE_PRESTEP, "A": MATCH_SIDE_PRESTEP,
"B": MATCH_SIDE_POSTACTUAL, "B": MATCH_SIDE_POSTACTUAL,
"shortA": "VS",
"shortB": "IN",
"longA": "Vor-Schritt",
"longB": "Ist-Nachher",
"mode": "action", "mode": "action",
"filename": "02_Vorschritt", "filename": "02_Vorschritt",
"title": "Schritt-Differenz (Vorschritt-Nachher - Ist-Nachher)" "title": "Schritt-Differenz (Vorschritt-Nachher - Ist-Nachher)"
@ -122,10 +106,6 @@ MATCH = {
MATCH_TESTEXAMPLE: { MATCH_TESTEXAMPLE: {
"A": MATCH_SIDE_TESTCASE, "A": MATCH_SIDE_TESTCASE,
"B": MATCH_SIDE_POSTACTUAL, "B": MATCH_SIDE_POSTACTUAL,
"shortA": "VS",
"shortB": "IN",
"longA": "Vor-Schritt",
"longB": "Ist-Nachher",
"mode": "action", "mode": "action",
"filename": "03_Vergleichstestfall", "filename": "03_Vergleichstestfall",
"title": "Schritt-Differenz (Vorschritt-Nachher - Ist-Nachher)" "title": "Schritt-Differenz (Vorschritt-Nachher - Ist-Nachher)"
@ -136,7 +116,7 @@ class Matching():
def __init__(self, comp): def __init__(self, comp):
self.comp = comp self.comp = comp
self.elements = {} self.elements = {}
self.matchfiles = comp.files self.matchfiles = {}
self.assignedFiles = {} self.assignedFiles = {}
self.linksA = {} self.linksA = {}
self.linksB = {} self.linksB = {}
@ -147,6 +127,7 @@ class Matching():
self.sideB = [] self.sideB = []
self.mode = "" self.mode = ""
self.matchtype = "" self.matchtype = ""
self.cssClass = "result0"
def setData(self, tdata, match): def setData(self, tdata, match):
""" """
@ -155,20 +136,28 @@ class Matching():
:param match: kind of actual match :param match: kind of actual match
:return: :return:
""" """
self.sideA = tdata[MATCH[match]["A"]]["data"] sideA = MATCH[match]["A"]
self.sideB = tdata[MATCH[match]["B"]]["data"] sideB = MATCH[match]["B"]
self.matchfiles["A"] = tdata[MATCH[match]["A"]]["path"] self.sideA = tdata[sideA]["data"]
self.matchfiles["B"] = tdata[MATCH[match]["B"]]["path"] self.sideB = tdata[sideB]["data"]
self.matchfiles["A"] = tdata[sideA]["path"]
self.matchfiles["B"] = tdata[sideB]["path"]
self.matchtype = match self.matchtype = match
self.mode = MATCH[match]["mode"] self.mode = MATCH[match]["mode"]
self.setDiffHeader() self.setDiffHeader()
self.report = utils.report_tool.Report.getInstance() self.report = utils.report_tool.Report.getInstance()
self.resetHits()
def resetHits(self): def resetHits(self):
self.linksA = {} self.linksA = {}
self.linksB = {} self.linksB = {}
self.nomatch = {} self.nomatch = {}
self.matchkeys = {} self.matchkeys = {}
self.cssClass = "result0"
def setCssClass(self, cssClass):
if cssClass > self.cssClass:
self.cssClass = cssClass
def isHitA(self, key): def isHitA(self, key):
return ((key in self.linksA) and (self.linksA[key] != "null")) return ((key in self.linksA) and (self.linksA[key] != "null"))
@ -206,8 +195,8 @@ class Matching():
htmltxt += "</head>" htmltxt += "</head>"
htmltxt += "<body>" htmltxt += "<body>"
htmltxt += "<h1>"+MATCH[matching.matchtype]["title"]+"</h1>" htmltxt += "<h1>"+MATCH[matching.matchtype]["title"]+"</h1>"
htmltxt += "<h4>" + MATCH[matching.matchtype]["longA"] +": " + matching.matchfiles["A"] + "</h4>" htmltxt += "<h4>"+MATCH[MATCH[matching.matchtype]["A"]]["long"]+": "+matching.matchfiles["A"]+"</h4>"
htmltxt += "<h4>" + MATCH[matching.matchtype]["longB"] +": " + matching.matchfiles["B"] + "</h4><br>" htmltxt += "<h4>"+MATCH[MATCH[matching.matchtype]["B"]]["long"]+": "+matching.matchfiles["B"]+"</h4><br>"
matching.htmltext = htmltxt matching.htmltext = htmltxt
def setDiffFooter(self): def setDiffFooter(self):
@ -235,6 +224,7 @@ def matchBestfit(matching, path):
:param matching: :param matching:
:return: :return:
""" """
# initialize all potential links with null
i=0 i=0
if (matching.sideA is not None): if (matching.sideA is not None):
for r in matching.sideA: for r in matching.sideA:
@ -249,11 +239,15 @@ def matchBestfit(matching, path):
i += 1 i += 1
ia = 0 ia = 0
ix = 1 ix = 1
# CASE: one side is None
if (matching.sideA is None) or (matching.sideB is None): if (matching.sideA is None) or (matching.sideB is None):
return return
# CASE: to match
for rA in matching.sideA: for rA in matching.sideA:
ib = 0 ib = 0
for rB in matching.sideB: for rB in matching.sideB:
if (matching.isHitA(composeKey("a", ia))):
continue
if (matching.isHitB(composeKey("b", ib))): if (matching.isHitB(composeKey("b", ib))):
ib += 1 ib += 1
continue continue
@ -374,10 +368,10 @@ def getEvaluation(matching, type, acceptance, sideA, sideB):
verify = int(job.getDebugLevel("match_tool"))-1 verify = int(job.getDebugLevel("match_tool"))-1
job.debug(verify, "getEvaluation "+str(sideA)+" ?= "+str(sideB)) job.debug(verify, "getEvaluation "+str(sideA)+" ?= "+str(sideB))
match = getStringSimilarity(str(sideA), str(sideB)) match = getStringSimilarity(str(sideA), str(sideB))
classA = "black" classA = "novalue"
classB = "black" classB = "novalue"
result = "test" result = "test"
if match == "99": return ["MATCH", "black", "black", "black", "black"] if match == "99": return ["MATCH", "novalue", "novalue", "novalue", "novalue"]
if acceptance == "ignore": result = "ignore" if acceptance == "ignore": result = "ignore"
if (matching.matchtype == MATCH_POSTCOND) and (result == "test"): if (matching.matchtype == MATCH_POSTCOND) and (result == "test"):
result = "hard" result = "hard"
@ -398,7 +392,7 @@ def matchDict(matching, A, B, path):
job.debug(verify, "matchDict 400 " + k + ".") job.debug(verify, "matchDict 400 " + k + ".")
if k in ["_match"]: if k in ["_match"]:
continue continue
if (B is not None) and (B[k]): if (B is not None) and (k in B):
if (isinstance(A[k], dict)): A[k]["_match"] = "Y" if (isinstance(A[k], dict)): A[k]["_match"] = "Y"
if (isinstance(B[k], dict)): B[k]["_match"] = "Y" if (isinstance(B[k], dict)): B[k]["_match"] = "Y"
job.debug(verify, "matchDict 404 " + k + "." + path) job.debug(verify, "matchDict 404 " + k + "." + path)
@ -412,7 +406,7 @@ def matchDict(matching, A, B, path):
job.debug(verify, "matchDict 412 " + k + ".") job.debug(verify, "matchDict 412 " + k + ".")
if k in ["_match"]: if k in ["_match"]:
continue continue
if (A is not None) and (A[k]): if (A is not None) and (k in A):
continue continue
elif (A is None) or (k not in A): elif (A is None) or (k not in A):
if (A is not None) and (isinstance(A[k], dict)): B[k]["_match"] = "N" if (A is not None) and (isinstance(A[k], dict)): B[k]["_match"] = "N"
@ -467,9 +461,11 @@ def compareRows(matching, path):
matching.sideB[int(extractKeyI(matching.linksA[k]))]) matching.sideB[int(extractKeyI(matching.linksA[k]))])
else: else:
htmltext += markRow(matching, header, matching.sideA[int(extractKeyI(k))], "A") htmltext += markRow(matching, header, matching.sideA[int(extractKeyI(k))], "A")
matching.setCssClass("result3")
for k in sorted(matching.linksB): for k in sorted(matching.linksB):
if (not matching.isHitB(k)): if (not matching.isHitB(k)):
htmltext += markRow(matching, header, matching.sideB[int(extractKeyI(k))], "B") htmltext += markRow(matching, header, matching.sideB[int(extractKeyI(k))], "B")
matching.setCssClass("result2")
htmltext += "</table>" htmltext += "</table>"
matching.difftext += "</table>" matching.difftext += "</table>"
return htmltext return htmltext
@ -480,15 +476,20 @@ def markRow(matching, header, row, side):
text = "" text = ""
cssClass = "" cssClass = ""
for f in header: for f in header:
if side == "A": if not f["field"] in row:
val = ""
cssClass = "novalue"
elif side == "A":
res = getEvaluation(matching, f["type"], f["acceptance"], row[f["field"]], "") res = getEvaluation(matching, f["type"], f["acceptance"], row[f["field"]], "")
val = str(row[f["field"]])
cssClass = res[1] cssClass = res[1]
else: else:
res = getEvaluation(matching, f["type"], f["acceptance"], "", row[f["field"]]) res = getEvaluation(matching, f["type"], f["acceptance"], "", row[f["field"]])
val = str(row[f["field"]])
cssClass = res[2] cssClass = res[2]
text += "<td "+utils.css_tool.getInlineStyle("diffFiles", cssClass)+">" + str(row[f["field"]]) + "</td>" text += "<td "+utils.css_tool.getInlineStyle("diffFiles", cssClass)+">"+val+"</td>"
text = "<tr><td "+utils.css_tool.getInlineStyle("diffFiles", cssClass)+">" \ text = "<tr><td "+utils.css_tool.getInlineStyle("diffFiles", cssClass)+">" \
+ MATCH[matching.matchtype]["short"+side] + "</td>" + text + "</tr>" + MATCH[MATCH[matching.matchtype][side]]["short"] + "</td>"+text+"</tr>"
matching.difftext += text matching.difftext += text
return text return text
@ -500,26 +501,51 @@ def compareRow(matching, header, rA, rB):
textA = "" textA = ""
textB = "" textB = ""
text = "" text = ""
valA = ""
valB = ""
classA = "novalue"
classB = "novalue"
for f in header: for f in header:
print(f) print(f)
if f["field"] in rA and f["field"] in rB:
res = getEvaluation(matching, f["type"], f["acceptance"], rA[f["field"]], rB[f["field"]]) res = getEvaluation(matching, f["type"], f["acceptance"], rA[f["field"]], rB[f["field"]])
match = res[0] match = res[0]
classA = res[1] classA = res[1]
classB = res[2] classB = res[2]
valA = str(rA[f["field"]])
valB = str(rB[f["field"]])
elif f["field"] in rA :
valA = str(rA[f["field"]])
match = "ddl"
classA = "acceptA"
classB = "acceptB"
elif f["field"] in rB:
valB = str(rB[f["field"]])
match = "ddl"
classA = "acceptA"
classB = "acceptB"
else:
match = "MATCH"
classA = "acceptA"
classB = "acceptB"
if (match == "MATCH"): if (match == "MATCH"):
textA += "<td>"+str(rA[f["field"]])+"</td>" textA += "<td>"+valA+"</td>"
textB += "<td>"+str(rB[f["field"]])+"</td>" textB += "<td>"+valB+"</td>"
matching.setCssClass("result1")
elif (match == "hard"): elif (match == "hard"):
allident = False allident = False
textA += "<td "+utils.css_tool.getInlineStyle("diffFiles", classA)+">" + str(rA[f["field"]]) + "</td>" textA += "<td "+utils.css_tool.getInlineStyle("diffFiles", classA)+">"+valA+"</td>"
textB += "<td "+utils.css_tool.getInlineStyle("diffFiles", classB)+">" + str(rB[f["field"]]) + "</td>" textB += "<td "+utils.css_tool.getInlineStyle("diffFiles", classB)+">"+valB+"</td>"
matching.setCssClass("result3")
else: else:
allident = False allident = False
textA += "<td "+utils.css_tool.getInlineStyle("diffFiles", classA)+">"+str(rA[f["field"]])+" ("+match+")</td>" textA += "<td "+utils.css_tool.getInlineStyle("diffFiles", classA)+">"+valA+" ("+match+")</td>"
textB += "<td "+utils.css_tool.getInlineStyle("diffFiles", classB)+">"+str(rB[f["field"]])+" ("+match+")</td>" textB += "<td "+utils.css_tool.getInlineStyle("diffFiles", classB)+">"+valB+" ("+match+")</td>"
matching.setCssClass("result1")
if allident: if allident:
return "<tr><td/>"+textA+"</tr>" return "<tr><td/>"+textA+"</tr>"
text = "<tr><td>"+MATCH[matching.matchtype]["shortA"]+"</td>"+textA+"</tr><tr><td>"+MATCH[matching.matchtype]["shortB"]+"</td>"+textB+"</tr>" text = "<tr><td>"+MATCH[MATCH[matching.matchtype]["A"]]["short"]+"</td>"+textA+"</tr>"
text += "<tr><td>"+MATCH[matching.matchtype]["shortB"]+"</td>"+textB+"</tr>"
matching.difftext += text matching.difftext += text
return text return text

Loading…
Cancel
Save