|
@ -3,6 +3,8 @@ import unittest |
|
|
|
|
|
|
|
|
import basic |
|
|
import basic |
|
|
from basic.program import Job |
|
|
from basic.program import Job |
|
|
|
|
|
import basic.constants as B |
|
|
|
|
|
import utils.data_const as D |
|
|
import utils.match_tool |
|
|
import utils.match_tool |
|
|
import utils.match_const as M |
|
|
import utils.match_const as M |
|
|
import components.component |
|
|
import components.component |
|
@ -56,15 +58,15 @@ tdata = { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
conf = { |
|
|
conf = { |
|
|
"ddl": { |
|
|
B.DATA_NODE_DDL: { |
|
|
"database": { |
|
|
"database": { |
|
|
"scheme": { |
|
|
"scheme": { |
|
|
"table": { |
|
|
"table": { |
|
|
"id": { "feld": "id", "type": "int", "acceptance": "ignore", "key": "T:3" }, |
|
|
"id": { D.DDL_FNAME: "id", D.DDL_TYPE: "int", D.DDL_ACCEPTANCE: "ignore", D.DDL_KEY: "T:3" }, |
|
|
"name": { "feld": "name", "type": "string", "acceptance": "must", "key": "F:1" }, |
|
|
"name": { D.DDL_FNAME: "name", D.DDL_TYPE: "string", D.DDL_ACCEPTANCE: "must", D.DDL_KEY: "F:1" }, |
|
|
"year": { "feld": "year", "type": "int", "acceptance": "must", "key": "F:2" }, |
|
|
"year": { D.DDL_FNAME: "year", D.DDL_TYPE: "int", D.DDL_ACCEPTANCE: "must", D.DDL_KEY: "F:2" }, |
|
|
"position": { "feld": "id", "type": "string", "acceptance": "must", "key": "" }, |
|
|
"position": { D.DDL_FNAME: "id", D.DDL_TYPE: "string", D.DDL_ACCEPTANCE: "must", D.DDL_KEY: "" }, |
|
|
"hobby": { "feld": "id", "type": "string", "acceptance": "must", "key": "" }, |
|
|
"hobby": { D.DDL_FNAME: "id", D.DDL_TYPE: "string", D.DDL_ACCEPTANCE: "must", D.DDL_KEY: "" }, |
|
|
"_header": ["id", "name", "year", "position", "hobby"] |
|
|
"_header": ["id", "name", "year", "position", "hobby"] |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -109,7 +111,7 @@ class MyTestCase(unittest.TestCase): |
|
|
self.assertEqual(matching.isHitB("b0005"), True, "doesnt exist") |
|
|
self.assertEqual(matching.isHitB("b0005"), True, "doesnt exist") |
|
|
self.assertEqual(("b0005" in matching.linksB), True, "doesnt exist") |
|
|
self.assertEqual(("b0005" in matching.linksB), True, "doesnt exist") |
|
|
|
|
|
|
|
|
def xtest_similarity(self): |
|
|
def test_similarity(self): |
|
|
matching = self.getMatching() |
|
|
matching = self.getMatching() |
|
|
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, |
|
@ -124,6 +126,7 @@ class MyTestCase(unittest.TestCase): |
|
|
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) |
|
|
|
|
|
matching.matchtype = M.MATCH_SUCCESS |
|
|
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"] |
|
|
utils.match_tool.matchBestfit(matching, ":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.name = "component" |
|
|
comp.conf = conf |
|
|
comp.conf = conf |
|
|
matching = self.getMatching() |
|
|
matching = self.getMatching() |
|
|
|
|
|
matching.matchtype = M.MATCH_SUCCESS |
|
|
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"] |
|
|
ddl = conf["ddl"]["database"]["scheme"]["table"] |
|
|
ddl = conf[B.DATA_NODE_DDL]["database"]["scheme"]["table"] |
|
|
header = [] |
|
|
header = [] |
|
|
for f in ddl["_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 |
|
|
i = 1 |
|
|
|
|
|
|
|
|
text = utils.match_tool.compareRow(matching, header, tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"][i], |
|
|
text = utils.match_tool.compareRow(matching, header, tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"][i], |
|
|