From 6a3cb565e6d65bff2694c3416fba4da22e9d4235 Mon Sep 17 00:00:00 2001 From: Ulrich Date: Sat, 20 Apr 2024 21:11:25 +0200 Subject: [PATCH] fixes for unittest 04, some new feature --- features/environment.py | 0 features/steps/steps.py | 0 test/test_04config.py | 27 +++++++++++++-------------- test/testtools.py | 4 ++-- tools/data_tool.py | 5 +++++ tools/file_type.py | 9 ++++++--- tools/make_tool.py | 0 7 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 features/environment.py create mode 100644 features/steps/steps.py create mode 100644 tools/make_tool.py diff --git a/features/environment.py b/features/environment.py new file mode 100644 index 0000000..e69de29 diff --git a/features/steps/steps.py b/features/steps/steps.py new file mode 100644 index 0000000..e69de29 diff --git a/test/test_04config.py b/test/test_04config.py index 11f91fb..4bdf313 100644 --- a/test/test_04config.py +++ b/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) diff --git a/test/testtools.py b/test/testtools.py index 4733ebe..8c8a641 100644 --- a/test/testtools.py +++ b/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 \ No newline at end of file diff --git a/tools/data_tool.py b/tools/data_tool.py index e7d5659..865082b 100644 --- a/tools/data_tool.py +++ b/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) diff --git a/tools/file_type.py b/tools/file_type.py index 7c2a18f..d9c7c4d 100644 --- a/tools/file_type.py +++ b/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(): """ diff --git a/tools/make_tool.py b/tools/make_tool.py new file mode 100644 index 0000000..e69de29