Browse Source

refactoring: basic-model - step+table

refactor
Ulrich 1 year ago
parent
commit
e6f8227010
  1. 35
      model/step.py
  2. 2
      test/test_28step.py
  3. 4
      test/test_29datatable.py

35
model/step.py

@ -78,7 +78,8 @@ class Step(model.entity.Entity):
:param opt. args additional args :param opt. args additional args
:return: list of entity-names :return: list of entity-names
""" """
config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, tools.config_tool.get_plain_filename(job, "")) config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS,
tools.config_tool.get_plain_filename(job, ""), B.SUBJECT_STEP)
outList = list(config[B.SUBJECT_VARIANTS].keys()) outList = list(config[B.SUBJECT_VARIANTS].keys())
return outList return outList
@ -89,21 +90,29 @@ class Step(model.entity.Entity):
:param name: :param name:
:return: :return:
""" """
config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, tools.config_tool.get_plain_filename(job, name)) config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS,
tools.config_tool.get_plain_filename(job, name), B.SUBJECT_STEP)
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def rest_read(self, job, name): @staticmethod
print("step read "+name) def rebuild_data(job, data: dict) -> dict:
variants = tools.config_tool.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS)["variants"] """
if name not in variants: gets the subtable-tag from filecsv and sets the subtables in order to workable entity-elements
raise Exception("Argument Variant "+name+" nicht definiert.") :param job:
variant = variants[name] :param data:
if not "comp" in variant: :return:
raise Exception("Keine Komponente zu "+name+" definiert.") """
cm = basic.componentHandling.ComponentManager.getInstance(job) data = tools.file_type.popSubjectsNode(job, data)
comp = cm.getComponent(variant["comp"]) # data = tools.file_type.popNameNode(job, data)
print(str(comp)) return data
@staticmethod
def check_data(job, data: dict) -> dict:
checkNodes = {}
checkNodes[tools.file_type.MUST_NODES] = []
checkNodes[tools.file_type.MUSTNT_NODES] = [B.DATA_NODE_OPTION, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS, B.DATA_NODE_HEADER]
checkNodes[tools.file_type.OPT_NODES] = [B.SUBJECT_COMP, B.NODE_ATTRIBUTES]
return tools.file_type.check_nodes(job, data, checkNodes)
def getIDName(self): def getIDName(self):
""" """

2
test/test_28step.py

@ -68,7 +68,7 @@ class MyTestCase(unittest.TestCase):
self.assertEqual(getattr(actstep, model.step.FIELD_NAME), name) self.assertEqual(getattr(actstep, model.step.FIELD_NAME), name)
self.assertRaises(Exception, step.read_entity, job, "xyzxyz") self.assertRaises(Exception, step.read_entity, job, "xyzxyz")
# #
testcase = model.testcase.Testcase(job, "TESTPROJ") testcase = model.testcase.Testcase(job)
tcname = "TC0001" tcname = "TC0001"
acttestcase = testcase.read_entity(job, tcname) acttestcase = testcase.read_entity(job, tcname)
print(str(acttestcase.steps)) print(str(acttestcase.steps))

4
test/test_29datatable.py

@ -31,7 +31,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
table = model.datatable.Datatable(job, "TESTPROJ") table = model.datatable.Datatable(job)
entityNames = table.read_unique_names(job, "", "", "", {}) entityNames = table.read_unique_names(job, "", "", "", {})
self.assertEqual(type(entityNames), list) self.assertEqual(type(entityNames), list)
#entityNames = project.select_unique_names(job, "", "", "", {}) #entityNames = project.select_unique_names(job, "", "", "", {})
@ -60,7 +60,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
table = model.datatable.Datatable(job, "TESTPROJ") table = model.datatable.Datatable(job)
name = "adress" name = "adress"
acttable = table.read_entity(job, name) acttable = table.read_entity(job, name)
self.assertEqual(getattr(acttable, model.datatable.FIELD_NAME), name) self.assertEqual(getattr(acttable, model.datatable.FIELD_NAME), name)

Loading…
Cancel
Save