|
@ -2,41 +2,52 @@ import json |
|
|
import unittest |
|
|
import unittest |
|
|
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 components.component |
|
|
import components.component |
|
|
|
|
|
|
|
|
tdata = { |
|
|
tdata = { |
|
|
"postReq": { |
|
|
M.MATCH_SIDE_POSTEXPECT: { |
|
|
"database": { |
|
|
"path": "", |
|
|
"scheme": { |
|
|
"data": { |
|
|
"table": { |
|
|
"database": { |
|
|
"_data": [] |
|
|
"scheme": { |
|
|
|
|
|
"table": { |
|
|
|
|
|
"_data": [] |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
"preAct": { |
|
|
M.MATCH_SIDE_PREACTUAL: { |
|
|
"database": { |
|
|
"path": "", |
|
|
"scheme": { |
|
|
"data": { |
|
|
"table": { |
|
|
"database": { |
|
|
"_data": [ |
|
|
"scheme": { |
|
|
{"id": 1, "name": "Brecht", "year": 2014, "position": "top", "hobby": "meaning"}, |
|
|
"table": { |
|
|
{"id": 2, "name": "Meier", "year": 2015, "position": "first", "hobby": "reading" }, |
|
|
"_data": [ |
|
|
{"id": 3, "name": "Smith", "year": 2018, "position": "second", "hobby": "writing"}, |
|
|
{"id": 1, "name": "Brecht", "year": 2014, "position": "top", "hobby": "meaning"}, |
|
|
{"id": 4, "name": "Smith", "year": 2019, "position": "third", "hobby": "executing"} |
|
|
{"id": 2, "name": "Meier", "year": 2015, "position": "first", "hobby": "reading" }, |
|
|
] |
|
|
{"id": 3, "name": "Smith", "year": 2018, "position": "second", "hobby": "writing"}, |
|
|
|
|
|
{"id": 4, "name": "Smith", "year": 2019, "position": "third", "hobby": "executing"} |
|
|
|
|
|
] |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
"postAct": { |
|
|
M.MATCH_SIDE_POSTACTUAL: { |
|
|
"database": { |
|
|
"path": "", |
|
|
"scheme": { |
|
|
"data": { |
|
|
"table": { |
|
|
"database": { |
|
|
"_data": [ |
|
|
"scheme": { |
|
|
{"id": 1, "name": "Brecht", "year": 2014, "position": "top", "hobby": "meaning"}, |
|
|
"table": { |
|
|
{"id": 2, "name": "Maier", "year": 2015, "position": "first", "hobby": "reading"}, |
|
|
"_data": [ |
|
|
{"id": 4, "name": "Smith", "year": 2018, "position": "second", "hobby": "writing"}, |
|
|
{"id": 1, "name": "Brecht", "year": 2014, "position": "top", "hobby": "meaning"}, |
|
|
{"id": 3, "name": "Smith", "year": 2019, "position": "third", "hobby": "executing"} |
|
|
{"id": 2, "name": "Maier", "year": 2015, "position": "first", "hobby": "reading"}, |
|
|
] |
|
|
{"id": 4, "name": "Smith", "year": 2018, "position": "second", "hobby": "writing"}, |
|
|
|
|
|
{"id": 3, "name": "Smith", "year": 2019, "position": "third", "hobby": "executing"} |
|
|
|
|
|
] |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -62,12 +73,12 @@ conf = { |
|
|
class MyTestCase(unittest.TestCase): |
|
|
class MyTestCase(unittest.TestCase): |
|
|
def runTest(self): |
|
|
def runTest(self): |
|
|
self.test_matchstart() |
|
|
self.test_matchstart() |
|
|
self.test_hitmanage() |
|
|
#self.test_hitmanage() |
|
|
self.test_similarity() |
|
|
#self.test_similarity() |
|
|
self.test_bestfit() |
|
|
#self.test_bestfit() |
|
|
self.test_compareRow() |
|
|
#self.test_compareRow() |
|
|
self.test_compareRows() |
|
|
#self.test_compareRows() |
|
|
self.test_match() |
|
|
#self.test_match() |
|
|
|
|
|
|
|
|
def test_matchstart(self): |
|
|
def test_matchstart(self): |
|
|
job = Job("unit") |
|
|
job = Job("unit") |
|
@ -75,10 +86,10 @@ 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.setData(tdata, utils.match_tool.MATCH_PREPOST) |
|
|
matching.setData(tdata, utils.match_tool.MATCH_SUCCESS) |
|
|
print(matching.htmltext) |
|
|
print(matching.htmltext) |
|
|
|
|
|
|
|
|
def test_hitmanage(self): |
|
|
def xtest_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.conf = conf |
|
|
comp.conf = conf |
|
@ -93,20 +104,20 @@ 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 test_similarity(self): |
|
|
def xtest_similarity(self): |
|
|
matching = self.getMatching() |
|
|
matching = self.getMatching() |
|
|
utils.match_tool.getSimilarity(matching, ":database:scheme:table:_data", |
|
|
utils.match_tool.getSimilarity(matching, ":database:scheme:table:_data", |
|
|
tdata["preAct"]["database"]["scheme"]["table"]["_data"][0], |
|
|
tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"][0], |
|
|
tdata["postAct"]["database"]["scheme"]["table"]["_data"][0],1) |
|
|
tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"][0],1) |
|
|
|
|
|
|
|
|
def test_bestfit(self): |
|
|
def xtest_bestfit(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/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.sideA = tdata["preAct"]["database"]["scheme"]["table"]["_data"] |
|
|
matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"] |
|
|
matching.sideB = tdata["postAct"]["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") |
|
|
print(json.dumps(matching.linksA)) |
|
|
print(json.dumps(matching.linksA)) |
|
|
print(json.dumps(matching.linksB)) |
|
|
print(json.dumps(matching.linksB)) |
|
@ -116,30 +127,32 @@ 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 test_compareRow(self): |
|
|
def xtest_compareRow(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/per.csv", "B": "/home/match/post.csv"} |
|
|
comp.conf = conf |
|
|
comp.conf = conf |
|
|
matching = self.getMatching() |
|
|
matching = self.getMatching() |
|
|
matching.sideA = tdata["preAct"]["database"]["scheme"]["table"]["_data"] |
|
|
matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"] |
|
|
matching.sideB = tdata["postAct"]["database"]["scheme"]["table"]["_data"] |
|
|
matching.sideB = tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"] |
|
|
ddl = conf["ddl"]["database"]["scheme"]["table"] |
|
|
ddl = conf["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({"field": f, "type": ddl[f]["type"], "acceptance": ddl[f]["acceptance"]}) |
|
|
i = 1 |
|
|
i = 1 |
|
|
text = utils.match_tool.compareRow(matching, header, tdata["preAct"]["database"]["scheme"]["table"]["_data"][i], tdata["postAct"]["database"]["scheme"]["table"]["_data"][i]) |
|
|
|
|
|
|
|
|
text = utils.match_tool.compareRow(matching, header, tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"][i], |
|
|
|
|
|
tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"]["_data"][i]) |
|
|
print(text) |
|
|
print(text) |
|
|
|
|
|
|
|
|
def test_compareRows(self): |
|
|
def xtest_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/per.csv", "B": "/home/match/post.csv"} |
|
|
comp.conf = conf |
|
|
comp.conf = conf |
|
|
matching = self.getMatching() |
|
|
matching = self.getMatching() |
|
|
matching.sideA = tdata["preAct"]["database"]["scheme"]["table"]["_data"] |
|
|
matching.sideA = tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"]["_data"] |
|
|
matching.sideB = tdata["postAct"]["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" } |
|
|
matching.linksA = linksA |
|
|
matching.linksA = linksA |
|
|
text = utils.match_tool.compareRows(matching, ":database:scheme:table:_data") |
|
|
text = utils.match_tool.compareRows(matching, ":database:scheme:table:_data") |
|
@ -165,7 +178,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.setData(tdata, utils.match_tool.MATCH_PREPOST) |
|
|
matching.setData(tdata, M.MATCH_SUCCESS) |
|
|
matching.difftext = "" |
|
|
matching.difftext = "" |
|
|
return matching |
|
|
return matching |
|
|
|
|
|
|
|
|