Browse Source

bugfixes match test

master
Ulrich Carmesin 2 years ago
parent
commit
81b3bf1fa6
  1. 22
      test/test_compare.py
  2. 8
      utils/match_tool.py
  3. 4
      utils/path_tool.py

22
test/test_compare.py

@ -3,6 +3,8 @@ import unittest
import basic
from basic.program import Job
import basic.constants as B
import utils.data_const as D
import utils.match_tool
import utils.match_const as M
import components.component
@ -56,15 +58,15 @@ tdata = {
}
}
conf = {
"ddl": {
B.DATA_NODE_DDL: {
"database": {
"scheme": {
"table": {
"id": { "feld": "id", "type": "int", "acceptance": "ignore", "key": "T:3" },
"name": { "feld": "name", "type": "string", "acceptance": "must", "key": "F:1" },
"year": { "feld": "year", "type": "int", "acceptance": "must", "key": "F:2" },
"position": { "feld": "id", "type": "string", "acceptance": "must", "key": "" },
"hobby": { "feld": "id", "type": "string", "acceptance": "must", "key": "" },
"id": { D.DDL_FNAME: "id", D.DDL_TYPE: "int", D.DDL_ACCEPTANCE: "ignore", D.DDL_KEY: "T:3" },
"name": { D.DDL_FNAME: "name", D.DDL_TYPE: "string", D.DDL_ACCEPTANCE: "must", D.DDL_KEY: "F:1" },
"year": { D.DDL_FNAME: "year", D.DDL_TYPE: "int", D.DDL_ACCEPTANCE: "must", D.DDL_KEY: "F:2" },
"position": { D.DDL_FNAME: "id", D.DDL_TYPE: "string", D.DDL_ACCEPTANCE: "must", D.DDL_KEY: "" },
"hobby": { D.DDL_FNAME: "id", D.DDL_TYPE: "string", D.DDL_ACCEPTANCE: "must", D.DDL_KEY: "" },
"_header": ["id", "name", "year", "position", "hobby"]
}
}
@ -109,7 +111,7 @@ class MyTestCase(unittest.TestCase):
self.assertEqual(matching.isHitB("b0005"), True, "doesnt exist")
self.assertEqual(("b0005" in matching.linksB), True, "doesnt exist")
def xtest_similarity(self):
def test_similarity(self):
matching = self.getMatching()
utils.match_tool.setMatchkeys(matching, ":database:scheme:table:_data")
utils.match_tool.getSimilarity(matching,
@ -124,6 +126,7 @@ class MyTestCase(unittest.TestCase):
comp.files = { "A": "/home/match/per.csv", "B": "/home/match/post.csv"}
comp.conf = conf
matching = utils.match_tool.Matching(comp)
matching.matchtype = M.MATCH_SUCCESS
matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"]
matching.sideB = tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"]
utils.match_tool.matchBestfit(matching, ":database:scheme:table:_data")
@ -143,12 +146,13 @@ class MyTestCase(unittest.TestCase):
comp.name = "component"
comp.conf = conf
matching = self.getMatching()
matching.matchtype = M.MATCH_SUCCESS
matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"]
matching.sideB = tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"]
ddl = conf["ddl"]["database"]["scheme"]["table"]
ddl = conf[B.DATA_NODE_DDL]["database"]["scheme"]["table"]
header = []
for f in ddl["_header"]:
header.append({"field": f, "type": ddl[f]["type"], "acceptance": ddl[f]["acceptance"]})
header.append({D.DDL_FNAME: f, D.DDL_TYPE: ddl[f][D.DDL_TYPE], D.DDL_ACCEPTANCE: ddl[f][D.DDL_ACCEPTANCE]})
i = 1
text = utils.match_tool.compareRow(matching, header, tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"][i],

8
utils/match_tool.py

@ -370,13 +370,13 @@ def matchDict(matching, A, B, path):
return matching
def matchArray(matching, A, B, path):
def matchArray(matching, sideA, sideB, path):
""" matches the datarows of the datatree """
job = basic.program.Job.getInstance()
verify = int(job.getDebugLevel("match_tool")) - 4
job.debug(verify, "matchArray " + path + "\n.." + matching.htmltext)
matching.sideA = A
matching.sideB = B
matching.sideA = sideA
matching.sideB = sideB
matchBestfit(matching, path)
matchRestfit(matching)
a = path.split(":")
@ -518,7 +518,7 @@ def compareRow(matching, header, rA, rB):
if allident:
return "<tr><td/>" + textA + "</tr>"
text = "<tr><td>" + M.MATCH[M.MATCH[matching.matchtype][M.M_SIDE_A]]["short"] + "</td>" + textA + "</tr>"
text += "<tr><td>" + M.MATCH[matching.matchtype]["shortB"] + "</td>" + textB + "</tr>"
text += "<tr><td>" + M.MATCH[M.MATCH[matching.matchtype][M.M_SIDE_B]]["short"] + "</td>" + textB + "</tr>"
matching.difftext += text
return text

4
utils/path_tool.py

@ -29,9 +29,9 @@ def getKeyValue(key, comp=None):
if comp is None:
raise Exception("Component is missing for "+key)
if utils.config_tool.hasAttr(comp.conf, key[5:]):
return utils.config_tool.gasAttr(comp.conf, key[5:])
return utils.config_tool.getAttr(comp.conf, key[5:])
if utils.config_tool.hasAttr(comp, key[5:]):
return utils.config_tool.gasAttr(comp, key[5:])
return utils.config_tool.getAttr(comp, key[5:])
return ""
elif 'env.' in key:
#if key[4:]

Loading…
Cancel
Save