Browse Source

fixes for unittest 04, some new feature

refactor
Ulrich 7 months ago
parent
commit
6a3cb565e6
  1. 0
      features/environment.py
  2. 0
      features/steps/steps.py
  3. 27
      test/test_04config.py
  4. 4
      test/testtools.py
  5. 5
      tools/data_tool.py
  6. 9
      tools/file_type.py
  7. 0
      tools/make_tool.py

0
features/environment.py

0
features/steps/steps.py

27
test/test_04config.py

@ -17,10 +17,11 @@ import test.constants as T
import test.testtools
import tools.path_const as P
import basic.constants as B
import tools.data_const as D
TEST_FUNCTIONS = ["test_01getConfigPath", "test_02mergeAttributes", "test_03getAttributes",
"test_20getPlainName"]
TEST_FUNCTIONS = ["test_01getConfigPath"]
#TEST_FUNCTIONS = ["test_01getConfigPath"]
verbose = False
class MyTestCase(unittest.TestCase):
@ -56,10 +57,8 @@ class MyTestCase(unittest.TestCase):
cnttest += 1
r = tools.config_tool.select_config_path(job, P.KEY_TESTSUITE, "TST001")
self.assertIn(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_TDATA], "TESTPROJ", B.SUBJECT_TESTSUITES, "TST001", "test"), r)
r = tools.config_tool.getConfig(job, P.KEY_TOOL, "path")
cnttest += 1
r = tools.config_tool.getConfig(job, P.KEY_TOOL, "path", ttype=D.CSV_SPECTYPE_KEYS)
if verbose: print("pattern " + r["pattern"]["log"])
if verbose: print("pattern " + r["pattern"]["precond"])
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
@ -73,22 +72,22 @@ class MyTestCase(unittest.TestCase):
return
job = test.testtools.getJob()
componentName = "testcm"
confs = tools.config_tool.getConfig(job, "comp", componentName)
confs = tools.config_tool.getConfig(job, "comp", componentName, ttype=D.CSV_SPECTYPE_COMP)
conns = tools.conn_tool.getConnections(job, componentName)
self.assertEqual(confs["conf"][B.TOPIC_INST][B.ATTR_INST_CNT], 1)
self.assertEqual(confs[B.SUBJECT_COMP][B.TOPIC_INST][B.ATTR_INST_CNT], 1)
self.assertEqual(conns[0][B.TOPIC_INST][B.ATTR_INST_CNT], 2)
self.assertNotIn(B.ATTR_INST_SGL, conns[0][B.TOPIC_INST])
confs["conf"] = tools.config_tool.mergeConn(job.m, confs["conf"], conns[0])
self.assertEqual(confs["conf"][B.TOPIC_INST][B.ATTR_INST_CNT], 2)
confs[B.SUBJECT_COMP] = tools.config_tool.mergeConn(job.m, confs[B.SUBJECT_COMP], conns[0])
self.assertEqual(confs[B.SUBJECT_COMP][B.TOPIC_INST][B.ATTR_INST_CNT], 2)
cnttest += 1 # it overwrites
self.assertEqual(confs["conf"][B.TOPIC_INST][B.ATTR_INST_SGL], "n")
self.assertEqual(confs[B.SUBJECT_COMP][B.TOPIC_INST][B.ATTR_INST_SGL], "n")
cnttest += 1 # it keep
componentName = "testprddb"
confs = tools.config_tool.getConfig(job, "comp", componentName)
confs = tools.config_tool.getConfig(job, "comp", componentName, ttype=D.CSV_SPECTYPE_COMP)
conns = tools.conn_tool.getConnections(job, componentName)
self.assertNotIn(B.ATTR_ARTS_TYPE, confs["conf"][B.SUBJECT_ARTIFACTS][B.TOPIC_NODE_DB])
confs["conf"] = tools.config_tool.mergeConn(job.m, confs["conf"], conns[0])
self.assertIn(B.ATTR_ARTS_TYPE, confs["conf"][B.SUBJECT_ARTIFACTS][B.TOPIC_NODE_DB])
self.assertNotIn(B.ATTR_ARTS_TYPE, confs[B.SUBJECT_COMP][B.SUBJECT_ARTIFACTS][B.TOPIC_NODE_DB])
confs[B.SUBJECT_COMP] = tools.config_tool.mergeConn(job.m, confs[B.SUBJECT_COMP], conns[0])
self.assertIn(B.ATTR_ARTS_TYPE, confs[B.SUBJECT_COMP][B.SUBJECT_ARTIFACTS][B.TOPIC_NODE_DB])
cnttest += 1 # new attribute
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)

4
test/testtools.py

@ -105,8 +105,8 @@ def getComp(job, componentName=""):
componentName = DEFAULT_COMP
comp.conf = {}
comp.name = componentName
confs = tools.config_tool.getConfig(job, "comp", componentName)
confs = tools.config_tool.getConfig(job, "comp", componentName, ttype=D.CSV_SPECTYPE_COMP)
conns = tools.conn_tool.getConnections(job, componentName)
comp.conf = confs["conf"]
comp.conf = confs[B.SUBJECT_COMP]
comp.conf[B.TOPIC_CONN] = conns[0]
return comp

5
tools/data_tool.py

@ -28,6 +28,11 @@ def getPluralKeyword(inkey):
return getPurKeyword(inkey)+"s"
def getSingularKeyword(inkey):
"""
singular word is mostly without ending s, except \"stories\"
:param inkey:
:return:
"""
if "stories" in inkey:
return B.SUBJECT_STORY
return getPurKeyword(inkey)

9
tools/file_type.py

@ -28,7 +28,7 @@ def rebuild_tdata(job, tdata: dict, tableAttr: dict, ttype:str) -> dict:
elif ttype + "s" in B.LIST_SUBJECTS or ttype == B.SUBJECT_USER:
enty = model.factory.get_entity_object(job, ttype, {})
return enty.rebuild_data(job, tdata)
elif ttype in ["basic", "tool"]:
elif ttype in ["basic", "tool", D.CSV_SPECTYPE_KEYS, D.CSV_SPECTYPE_COMP]:
return tdata
else:
raise Exception("ttype is not defined " + ttype)
@ -112,7 +112,9 @@ def check_tdata(job, tdata: dict, ttype:str) -> dict:
elif ttype + "s" in B.LIST_SUBJECTS or ttype == B.SUBJECT_USER:
enty = model.factory.get_entity_object(job, ttype, {})
return enty.check_data(job, tdata)
elif ttype in ["basic"]:
elif ttype in [D.CSV_SPECTYPE_KEYS]:
return tdata
elif ttype in ["basic", "tool"]:
return tdata
else:
job.m.logError("ttype is not defined " + ttype)
@ -147,7 +149,8 @@ def checkComp(job, tdata: dict) -> dict:
checkNodes[MUST_NODES] = [B.SUBJECT_ARTIFACTS, B.SUBJECT_STEPS, "functions", B.SUBJECT_DATATABLES]
checkNodes[MUSTNT_NODES] = [B.DATA_NODE_DATA]
checkNodes[OPT_NODES] = []
return check_nodes(job, tdata, checkNodes)
check_nodes(job, tdata[B.SUBJECT_COMP], checkNodes)
return tdata
class DatatypeCatalog():
"""

0
tools/make_tool.py

Loading…
Cancel
Save