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
: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())
return outList
@ -89,21 +90,29 @@ class Step(model.entity.Entity):
:param name:
: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)
def rest_read(self, job, name):
print("step read "+name)
variants = tools.config_tool.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS)["variants"]
if name not in variants:
raise Exception("Argument Variant "+name+" nicht definiert.")
variant = variants[name]
if not "comp" in variant:
raise Exception("Keine Komponente zu "+name+" definiert.")
cm = basic.componentHandling.ComponentManager.getInstance(job)
comp = cm.getComponent(variant["comp"])
print(str(comp))
@staticmethod
def rebuild_data(job, data: dict) -> dict:
"""
gets the subtable-tag from filecsv and sets the subtables in order to workable entity-elements
:param job:
:param data:
:return:
"""
data = tools.file_type.popSubjectsNode(job, data)
# data = tools.file_type.popNameNode(job, data)
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):
"""

2
test/test_28step.py

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

4
test/test_29datatable.py

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

Loading…
Cancel
Save