|
|
@ -1,6 +1,6 @@ |
|
|
import json |
|
|
import json |
|
|
import unittest |
|
|
import unittest |
|
|
|
|
|
import inspect |
|
|
import basic |
|
|
import basic |
|
|
from basic.program import Job |
|
|
from basic.program import Job |
|
|
import basic.constants as B |
|
|
import basic.constants as B |
|
|
@ -8,6 +8,15 @@ 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 basic.component |
|
|
import basic.component |
|
|
|
|
|
import test.testtools |
|
|
|
|
|
|
|
|
|
|
|
# the list of TEST_FUNCTIONS defines which function will be really tested. |
|
|
|
|
|
# if you minimize the list you can check the specific test-function |
|
|
|
|
|
TEST_FUNCTIONS = ["test_01matchstart", "test_02hitmanage", "test_03similarity", "test_04bestfit", |
|
|
|
|
|
"test_11compareRow", "test_12compareRows", "test_21match"] |
|
|
|
|
|
# TEST_FUNCTIONS = ["test_getCsvSpec_data"] |
|
|
|
|
|
# with this variable you can switch prints on and off |
|
|
|
|
|
verbose = False |
|
|
|
|
|
|
|
|
tdata = { |
|
|
tdata = { |
|
|
M.MATCH_SIDE_POSTEXPECT: { |
|
|
M.MATCH_SIDE_POSTEXPECT: { |
|
|
@ -90,8 +99,13 @@ class MyTestCase(unittest.TestCase): |
|
|
#self.test_compareRows() |
|
|
#self.test_compareRows() |
|
|
#self.test_match() |
|
|
#self.test_match() |
|
|
|
|
|
|
|
|
def test_matchstart(self): |
|
|
def test_01matchstart(self): |
|
|
job = Job("unit") |
|
|
global mymsg |
|
|
|
|
|
actfunction = str(inspect.currentframe().f_code.co_name) |
|
|
|
|
|
cnttest = 0 |
|
|
|
|
|
if actfunction not in TEST_FUNCTIONS: |
|
|
|
|
|
return |
|
|
|
|
|
job = test.testtools.getJob() |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
comp = basic.component.Component() |
|
|
comp = basic.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"} |
|
|
@ -101,7 +115,12 @@ class MyTestCase(unittest.TestCase): |
|
|
matching.setData(tdata, M.MATCH_SUCCESS) |
|
|
matching.setData(tdata, M.MATCH_SUCCESS) |
|
|
print(matching.htmltext) |
|
|
print(matching.htmltext) |
|
|
|
|
|
|
|
|
def test_hitmanage(self): |
|
|
def test_02hitmanage(self): |
|
|
|
|
|
global mymsg |
|
|
|
|
|
actfunction = str(inspect.currentframe().f_code.co_name) |
|
|
|
|
|
cnttest = 0 |
|
|
|
|
|
if actfunction not in TEST_FUNCTIONS: |
|
|
|
|
|
return |
|
|
comp = basic.component.Component() |
|
|
comp = basic.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.name = "component" |
|
|
@ -117,15 +136,25 @@ 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 test_03similarity(self): |
|
|
|
|
|
global mymsg |
|
|
|
|
|
actfunction = str(inspect.currentframe().f_code.co_name) |
|
|
|
|
|
cnttest = 0 |
|
|
|
|
|
if actfunction not in TEST_FUNCTIONS: |
|
|
|
|
|
return |
|
|
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, |
|
|
tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA][0], |
|
|
tdata[M.MATCH_SIDE_PREACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA][0], |
|
|
tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA][0], 1) |
|
|
tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA][0], 1) |
|
|
|
|
|
|
|
|
def test_bestfit(self): |
|
|
def test_04bestfit(self): |
|
|
job = Job("unit") |
|
|
global mymsg |
|
|
|
|
|
actfunction = str(inspect.currentframe().f_code.co_name) |
|
|
|
|
|
cnttest = 0 |
|
|
|
|
|
if actfunction not in TEST_FUNCTIONS: |
|
|
|
|
|
return |
|
|
|
|
|
job = test.testtools.getJob() |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
comp = basic.component.Component() |
|
|
comp = basic.component.Component() |
|
|
comp.name = "component" |
|
|
comp.name = "component" |
|
|
@ -144,8 +173,13 @@ 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 test_11compareRow(self): |
|
|
job = Job("unit") |
|
|
global mymsg |
|
|
|
|
|
actfunction = str(inspect.currentframe().f_code.co_name) |
|
|
|
|
|
cnttest = 0 |
|
|
|
|
|
if actfunction not in TEST_FUNCTIONS: |
|
|
|
|
|
return |
|
|
|
|
|
job = test.testtools.getJob() |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
comp = basic.component.Component() |
|
|
comp = basic.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"} |
|
|
@ -165,8 +199,13 @@ class MyTestCase(unittest.TestCase): |
|
|
tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA][i]) |
|
|
tdata[M.MATCH_SIDE_POSTACTUAL]["data"]["database"]["scheme"]["table"][B.DATA_NODE_DATA][i]) |
|
|
print(text) |
|
|
print(text) |
|
|
|
|
|
|
|
|
def test_compareRows(self): |
|
|
def test_12compareRows(self): |
|
|
job = Job("unit") |
|
|
global mymsg |
|
|
|
|
|
actfunction = str(inspect.currentframe().f_code.co_name) |
|
|
|
|
|
cnttest = 0 |
|
|
|
|
|
if actfunction not in TEST_FUNCTIONS: |
|
|
|
|
|
return |
|
|
|
|
|
job = test.testtools.getJob() |
|
|
comp = basic.component.Component() |
|
|
comp = basic.component.Component() |
|
|
comp.files = { "A": "/home/match/pre.csv", "B": "/home/match/post.csv"} |
|
|
comp.files = { "A": "/home/match/pre.csv", "B": "/home/match/post.csv"} |
|
|
comp.name = "component" |
|
|
comp.name = "component" |
|
|
@ -182,28 +221,33 @@ class MyTestCase(unittest.TestCase): |
|
|
text = utils.match_tool.compareRows(matching, ":database:scheme:table:_data") |
|
|
text = utils.match_tool.compareRows(matching, ":database:scheme:table:_data") |
|
|
print(text) |
|
|
print(text) |
|
|
|
|
|
|
|
|
def test_match(self): |
|
|
def test_21match(self): |
|
|
job = Job("unit") |
|
|
global mymsg |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
actfunction = str(inspect.currentframe().f_code.co_name) |
|
|
setattr(job.par, "tctime", "2022-03-25_19-25-31") |
|
|
cnttest = 0 |
|
|
comp = basic.component.Component() |
|
|
if actfunction not in TEST_FUNCTIONS: |
|
|
comp.files = {"A": "/home/match/per.csv", "B": "/home/match/post.csv"} |
|
|
return |
|
|
comp.name = "component" |
|
|
job = test.testtools.getJob() |
|
|
cm = basic.componentHandling.ComponentManager() |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
cm.comps["component"] = comp |
|
|
setattr(job.par, "tctime", "2022-03-25_19-25-32") |
|
|
# tdata["postReq"] = tdata["preAct"] |
|
|
comp = basic.component.Component() |
|
|
comp.conf = conf |
|
|
comp.files = {"A": "/home/match/per.csv", "B": "/home/match/post.csv"} |
|
|
matching = utils.match_tool.Matching(comp) |
|
|
comp.name = "component" |
|
|
matching.htmltext = "" |
|
|
cm = basic.componentHandling.ComponentManager() |
|
|
matching.setData(tdata, M.MATCH_POSTCOND) |
|
|
cm.comps["component"] = comp |
|
|
text = utils.match_tool.matchTree(matching) |
|
|
# tdata["postReq"] = tdata["preAct"] |
|
|
print("\n-------------\n") |
|
|
comp.conf = conf |
|
|
print(text) |
|
|
matching = utils.match_tool.Matching(comp) |
|
|
print("\n-------------\n") |
|
|
matching.htmltext = "" |
|
|
print(matching.difftext) |
|
|
matching.setData(tdata, M.MATCH_POSTCOND) |
|
|
|
|
|
text = utils.match_tool.matchTree(matching) |
|
|
|
|
|
print("\n-------------\n") |
|
|
|
|
|
print(text) |
|
|
|
|
|
print("\n-------------\n") |
|
|
|
|
|
print(matching.difftext) |
|
|
|
|
|
|
|
|
def getMatching(self): |
|
|
def getMatching(self): |
|
|
job = Job("unit") |
|
|
job = test.testtools.getJob() |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
setattr(job.par, B.PAR_TESTCASE, "TC0001") |
|
|
setattr(job.par, "tctime", "2022-03-25_19-25-31") |
|
|
setattr(job.par, "tctime", "2022-03-25_19-25-31") |
|
|
comp = basic.component.Component() |
|
|
comp = basic.component.Component() |