Compare commits

...

2 Commits

  1. 1
      .gitignore
  2. 20
      test/test_31db.py
  3. 17
      testrest/CONFIG.yml
  4. 2
      testrest/Testrest.py
  5. 32
      testrest/mapping-rest.yml

1
.gitignore

@ -1,4 +1,5 @@
__pycache__
*/__pycache__/*
..
temp

20
test/test_31db.py

@ -15,7 +15,7 @@ import basic.constants as B
import utils.db_abstract
import test.testtools
import utils.config_tool
import utils.data_const as D
HOME_PATH = test.constants.HOME_PATH
conf = {}
@ -39,7 +39,7 @@ class MyTestCase(unittest.TestCase):
table = "person"
comp.conf = {}
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])
self.assertEqual(res, ["persid"])
@ -57,14 +57,14 @@ class MyTestCase(unittest.TestCase):
table = "person"
comp.conf = {}
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][B.TOPIC_NODE_DB] = {}
comp.conf[B.SUBJECT_CONN] = {}
comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB] = {}
comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][B.ATTR_TYPE] = "rel"
comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][B.ATTR_DB_DATABASE] = "crm-db"
tool = basic.toolHandling.getDbTool(comp)
tool = basic.toolHandling.getDbTool(job, comp)
self.assertRegex(str(type(tool)), 'dbrel_tool.DbFcts')
def test_02parseSql(self):
@ -79,14 +79,14 @@ class MyTestCase(unittest.TestCase):
table = "person"
comp.conf = {}
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][B.TOPIC_NODE_DB] = {}
comp.conf[B.SUBJECT_CONN] = {}
comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB] = {}
comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][B.ATTR_TYPE] = "rel"
comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][B.ATTR_DB_DATABASE] = "crm-db"
tool = basic.toolHandling.getDbTool(comp)
tool = basic.toolHandling.getDbTool(job, comp)
attr = tool.getDbAttributes("xx")
self.assertRegex(attr[B.ATTR_DB_PARTITION], 'n')
comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "y"
@ -96,12 +96,12 @@ class MyTestCase(unittest.TestCase):
attr = tool.getDbAttributes("xx")
self.assertRegex(attr[B.ATTR_DB_PARTITION], 'z')
#
sqls = comp.composeSqlClauses("SELECT * FROM person")
sqls = comp.composeSqlClauses(job, "SELECT * FROM person")
print(sqls)
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+!")
#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)
self.assertNotIn("street", sqls["ALL"]) #assertEqual(("street" in sqls), True)
self.assertIn("famname", sqls["ALL"])
@ -109,12 +109,12 @@ class MyTestCase(unittest.TestCase):
# TODO replace the formula with job-parameter
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+"
sqls = comp.composeSqlClauses("SELECT * FROM person")
sqls = comp.composeSqlClauses(job, "SELECT * FROM person")
print(sqls)
self.assertIn("famname", sqls["ALL"])
self.assertIn("sex", sqls["ALL"])
setattr(job.par, B.PAR_DB_PARTITION, "m,w")
sqls = comp.composeSqlClauses("SELECT * FROM person")
sqls = comp.composeSqlClauses(job, "SELECT * FROM person")
print(sqls)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)

17
testrest/CONFIG.yml

@ -13,14 +13,27 @@ conf:
execute_testcase: "todo"
collect_testcase: "todo" # -> postcondition, check data
compare_testcase: "todo" # -> postcondition, check data
_steps:
xml-rest:
- tool: file
type: xml
fct: create
- tool: cli
cmd: "cp-to {}"
json-rest:
- tool: file
type: json
fct: create
- tool: cli
cmd: "cp-to {}"
artifact:
file:
reset: testcase
jsonrest:
json-rest:
name: json-rest
type: json
path: requests
xmlrest:
xml-rest:
name: xml-rest
type: xml
path: requests

2
testrest/Testrest.py

@ -11,7 +11,7 @@ class Testrest(basic.component.Component):
:param step:
:return:
"""
fileClass = basic.toolHandling.getDbTool(self)
fileClass = basic.toolHandling.getDbTool(job, self)
pass

32
testrest/mapping-rest.yml

@ -0,0 +1,32 @@
rest:
sender:
_id: "sender={_data.person._sender(_steps._nr)}"
client-name: "{_catalog.sender.name(sender)}"
client-id: "{_catalog.sender.client-id(sender)}"
client-depart: "{_catalog.sender.department(sender)}"
messages:
_foreach: "msgid={_steps._nr}"
message:
'@nr': "{msgid}"
'@action': "{_steps.args.action}"
#msgid: "{gen.genId(n8)}"
timestamp: "{_par.tctime}"
customer:
_id: "{msgid}"
_row: "{_data.person(msgid)}"
name: "{_row.person.name}"
famname: "{_row.person.famname}"
adress:
_id: "{msgid}"
_row: "{_data.adress(msgid)}"
street: "{_row.adress.street}"
city: "{_row.adress.city}"
zip: "{_row.adress.zip}"
position:
_foreach: "posid={_data.product._nr,_pos(msgid)}"
#'@id': "$i"
product:
_id: "{posid}"
_row: "{_data.product(posid)}"
description: "{_row.product.descript}"
prdtype: "{_row.product.objtype}"
Loading…
Cancel
Save