|
@ -15,7 +15,7 @@ import basic.constants as B |
|
|
import utils.db_abstract |
|
|
import utils.db_abstract |
|
|
import test.testtools |
|
|
import test.testtools |
|
|
import utils.config_tool |
|
|
import utils.config_tool |
|
|
|
|
|
import utils.data_const as D |
|
|
HOME_PATH = test.constants.HOME_PATH |
|
|
HOME_PATH = test.constants.HOME_PATH |
|
|
|
|
|
|
|
|
conf = {} |
|
|
conf = {} |
|
@ -39,7 +39,7 @@ class MyTestCase(unittest.TestCase): |
|
|
table = "person" |
|
|
table = "person" |
|
|
comp.conf = {} |
|
|
comp.conf = {} |
|
|
comp.conf[B.DATA_NODE_DDL] = {} |
|
|
comp.conf[B.DATA_NODE_DDL] = {} |
|
|
comp.conf[B.DATA_NODE_DDL][table] = utils.config_tool.getConfig("DATASTRUCTURE", comp.name, table) |
|
|
comp.conf[B.DATA_NODE_DDL][table] = utils.config_tool.getConfig(job, D.DDL_FILENAME, comp.name, table) |
|
|
res = utils.db_abstract.getTechnicalIDFields(comp.conf[B.DATA_NODE_DDL][table]) |
|
|
res = utils.db_abstract.getTechnicalIDFields(comp.conf[B.DATA_NODE_DDL][table]) |
|
|
self.assertEqual(res, ["persid"]) |
|
|
self.assertEqual(res, ["persid"]) |
|
|
|
|
|
|
|
@ -57,7 +57,7 @@ class MyTestCase(unittest.TestCase): |
|
|
table = "person" |
|
|
table = "person" |
|
|
comp.conf = {} |
|
|
comp.conf = {} |
|
|
comp.conf[B.DATA_NODE_DDL] = {} |
|
|
comp.conf[B.DATA_NODE_DDL] = {} |
|
|
comp.conf[B.DATA_NODE_DDL][table] = utils.config_tool.getConfig("DATASTRUCTURE", comp.name, table) |
|
|
comp.conf[B.DATA_NODE_DDL][table] = utils.config_tool.getConfig(job, D.DDL_FILENAME, comp.name, table) |
|
|
comp.conf[B.SUBJECT_ARTS] = {} |
|
|
comp.conf[B.SUBJECT_ARTS] = {} |
|
|
comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB] = {} |
|
|
comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB] = {} |
|
|
comp.conf[B.SUBJECT_CONN] = {} |
|
|
comp.conf[B.SUBJECT_CONN] = {} |
|
@ -79,7 +79,7 @@ class MyTestCase(unittest.TestCase): |
|
|
table = "person" |
|
|
table = "person" |
|
|
comp.conf = {} |
|
|
comp.conf = {} |
|
|
comp.conf[B.DATA_NODE_DDL] = {} |
|
|
comp.conf[B.DATA_NODE_DDL] = {} |
|
|
comp.conf[B.DATA_NODE_DDL][table] = utils.config_tool.getConfig("DATASTRUCTURE", comp.name, table) |
|
|
comp.conf[B.DATA_NODE_DDL][table] = utils.config_tool.getConfig(job, D.DDL_FILENAME, comp.name, table) |
|
|
comp.conf[B.SUBJECT_ARTS] = {} |
|
|
comp.conf[B.SUBJECT_ARTS] = {} |
|
|
comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB] = {} |
|
|
comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB] = {} |
|
|
comp.conf[B.SUBJECT_CONN] = {} |
|
|
comp.conf[B.SUBJECT_CONN] = {} |
|
@ -96,12 +96,12 @@ class MyTestCase(unittest.TestCase): |
|
|
attr = tool.getDbAttributes("xx") |
|
|
attr = tool.getDbAttributes("xx") |
|
|
self.assertRegex(attr[B.ATTR_DB_PARTITION], 'z') |
|
|
self.assertRegex(attr[B.ATTR_DB_PARTITION], 'z') |
|
|
# |
|
|
# |
|
|
sqls = comp.composeSqlClauses("SELECT * FROM person") |
|
|
sqls = comp.composeSqlClauses(job, "SELECT * FROM person") |
|
|
print(sqls) |
|
|
print(sqls) |
|
|
self.assertEqual(sqls["ALL"], "SELECT * FROM crm-db.person ORDER BY persid") |
|
|
self.assertEqual(sqls["ALL"], "SELECT * FROM crm-db.person ORDER BY persid") |
|
|
setattr(job.par, B.PAR_DB_WHERE, "famname like !%utz%! and state = !+reg+!") |
|
|
setattr(job.par, B.PAR_DB_WHERE, "famname like !%utz%! and state = !+reg+!") |
|
|
#comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" |
|
|
#comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" |
|
|
sqls = comp.composeSqlClauses("SELECT * FROM person") |
|
|
sqls = comp.composeSqlClauses(job, "SELECT * FROM person") |
|
|
print(sqls) |
|
|
print(sqls) |
|
|
self.assertNotIn("street", sqls["ALL"]) #assertEqual(("street" in sqls), True) |
|
|
self.assertNotIn("street", sqls["ALL"]) #assertEqual(("street" in sqls), True) |
|
|
self.assertIn("famname", sqls["ALL"]) |
|
|
self.assertIn("famname", sqls["ALL"]) |
|
@ -109,12 +109,12 @@ class MyTestCase(unittest.TestCase): |
|
|
# TODO replace the formula with job-parameter |
|
|
# TODO replace the formula with job-parameter |
|
|
setattr(job.par, B.PAR_DB_WHERE, "famname like !%utz%! and sex = {job.par.sex}") |
|
|
setattr(job.par, B.PAR_DB_WHERE, "famname like !%utz%! and sex = {job.par.sex}") |
|
|
#comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" |
|
|
#comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" |
|
|
sqls = comp.composeSqlClauses("SELECT * FROM person") |
|
|
sqls = comp.composeSqlClauses(job, "SELECT * FROM person") |
|
|
print(sqls) |
|
|
print(sqls) |
|
|
self.assertIn("famname", sqls["ALL"]) |
|
|
self.assertIn("famname", sqls["ALL"]) |
|
|
self.assertIn("sex", sqls["ALL"]) |
|
|
self.assertIn("sex", sqls["ALL"]) |
|
|
setattr(job.par, B.PAR_DB_PARTITION, "m,w") |
|
|
setattr(job.par, B.PAR_DB_PARTITION, "m,w") |
|
|
sqls = comp.composeSqlClauses("SELECT * FROM person") |
|
|
sqls = comp.composeSqlClauses(job, "SELECT * FROM person") |
|
|
print(sqls) |
|
|
print(sqls) |
|
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
|
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
|
|
|
|
|
|
|
|