Browse Source

read testcase with subtable-objects

refactor
Ulrich 1 year ago
parent
commit
602e5dda15
  1. 3
      basic/constants.py
  2. 25
      model/application.py
  3. 41
      model/component.py
  4. 25
      model/datatable.py
  5. 48
      model/entity.py
  6. 34
      model/environment.py
  7. 4
      model/factory.py
  8. 38
      model/project.py
  9. 26
      model/release.py
  10. 75
      model/step.py
  11. 26
      model/story.py
  12. 26
      model/table.py
  13. 41
      model/testcase.py
  14. 26
      model/testplan.py
  15. 26
      model/testsuite.py
  16. 26
      model/topic.py
  17. 26
      model/usecase.py
  18. 26
      model/user.py
  19. 26
      model/variant.py
  20. 4
      test/test_27testcase.py
  21. 15
      tools/data_tool.py
  22. 13
      tools/filecsv_fcts.py

3
basic/constants.py

@ -185,7 +185,8 @@ ATTR_ARTS_RESET = "reset"
ATTR_ARTS_PRESTEP = "prestep"
""" optional attribute to define a source-table for this table """
LIST_ARTS_ATTR = [ATTR_ARTS_TYPE, ATTR_ARTS_PATH, ATTR_ARTS_RESET, ATTR_ARTS_PRESTEP, ATTR_ARTS_NAME]
SUBJECT_VARIANTS = "variants"
SUBJECT_VARIANT = "variant"
SUBJECT_VARIANTS = SUBJECT_VARIANT + "s"
SUBJECT_ENVIRONMENT = 'environment'
SUBJECT_ENVIRONMENTS = SUBJECT_ENVIRONMENT + "s"
SUBJECT_STORY = "story"

25
model/application.py

@ -267,14 +267,39 @@ class Application(model.entity.Entity):
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name
class Application_old(model.entity.Entity):
table = "application"

41
model/component.py

@ -23,10 +23,13 @@ FIELD_NAME = D.FIELD_NAME
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_APPLICATION = B.SUBJECT_APP
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE]
""" list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES, B.DATA_NODE_TOPICS]
LIST_SUBTABLES = {
}
CP_SUBJECT_COMPS = "components"
CP_SUBJECT_STEPS = "steps"
@ -116,6 +119,40 @@ class Component(model.entity.Entity):
continue
setattr(self, k, config[TABLE_NAME][k])
return self
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name
def write_entity(self, job, name):
return

25
model/datatable.py

@ -32,11 +32,36 @@ class Datatable(model.entity.Entity):
self.job = job
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name

48
model/entity.py

@ -310,22 +310,36 @@ class Entity:
:param subjects: list of subtables-names, the model-const LIST_SUBTABLES
:return:
"""
setattr(self, D.FIELD_NAME, rootname)
""" 2023-05 """
verify = False
for k in fields + nodes:
key = tools.data_tool.getExistKeyword(k, config[rootname])
if key in ["", D.FIELD_NAME, D.FIELD_PROJECT]:
if verify: print("setFields " + k + " / " + key)
if key in ["", D.FIELD_PROJECT]:
continue
setattr(self, k, config[rootname][key])
if verify: print("setFields " + str(k) + " = " + str(config[rootname][key]))
if k in fields:
setattr(self, tools.data_tool.getSingularKeyword(k), tools.data_tool.getValueStr(config[rootname][key]))
else:
setattr(self, tools.data_tool.getSingularKeyword(k), config[rootname][key])
if getattr(self, D.FIELD_NAME, "") == "":
setattr(self, D.FIELD_NAME, rootname)
for k in subjects:
if k in [B.DATA_NODE_DATA, B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_ROW]:
continue
objects = {}
key = tools.data_tool.getExistKeyword(k, config[rootname])
if key == "":
continue
for o in config[rootname][key]:
if o in [B.DATA_NODE_DATA, B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_ROW]:
continue
args = {}
args[k] = config[rootname][key][o]
objects[o] = model.factory.get_entity_object(self.job, k, args)
if verify: print("setSubObject " + o + " = " + str(args[k]))
object = model.factory.get_entity_object(self.job, k, args)
objects[object.getIDName()] = object
if verify: print("setSubtables " + k + " = " + str(objects))
setattr(self, k, objects)
topics = {}
key = tools.data_tool.getExistKeyword(B.DATA_NODE_TOPICS, config[rootname])
@ -337,14 +351,40 @@ class Entity:
return self
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return []
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return []
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return {}
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return ""
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return ""
def setSubtable(self, job, subtable, sublist):
outDict = {}
for k in sublist:

34
model/environment.py

@ -107,3 +107,37 @@ class Environment(model.entity.Entity):
config = self.getConfig(job, P.KEY_ENV, name, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name

4
model/factory.py

@ -10,6 +10,8 @@ def get_entity_object(job, name, args):
entity = getVariant(job)
elif name in B.SUBJECT_DATATABLES:
entity = getDatatable(job)
elif name in B.SUBJECT_USECASES:
entity = getUsecase(job)
elif name in B.SUBJECT_APPS:
entity = getApplication(job)
elif name in B.SUBJECT_COMPS:
@ -18,6 +20,8 @@ def get_entity_object(job, name, args):
entity = getTestcase(job)
elif name in B.SUBJECT_TESTSUITES:
entity = getTestsuite(job)
elif name in B.SUBJECT_TESTPLAN:
entity = getTestplan(job)
else:
return None
entity.setAttributes(job, args, name, entity.getFieldList(), entity.getNodeList(), entity.getSubtableList())

38
model/project.py

@ -21,7 +21,8 @@ FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE]
""" list of object-attributes """
LIST_NODES = []
LIST_SUBTABLES = {}
FILE_EXTENSION = D.DFILE_TYPE_YML
UNIQUE_FIELDS = [FIELD_NAME]
""" unique business field as human identifer """
@ -97,6 +98,41 @@ class Project(model.entity.Entity):
setattr(self, k, config[k])
return self
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name
def select_entity(self, job, name, row={}):
"""
reads the entity from the database

26
model/release.py

@ -74,10 +74,36 @@ class Release(model.entity.Entity):
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name

75
model/step.py

@ -17,11 +17,12 @@ TABLE_NAME = "step"
""" system-name for this entity """
FIELD_ID = "spid"
FIELD_NAME = "name"
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_COMPONENT = B.SUBJECT_COMP
FIELD_VARIANT = B.SUBJECT_VARIANT
FIELD_SORTNR = "sortnr"
FIELD_STEPNR = "stepnr"
FIELD_DATAREF = "dataref"
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_COMPONENT]
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_VARIANT, FIELD_SORTNR, FIELD_STEPNR, FIELD_DATAREF]
""" list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES, B.DATA_NODE_TOPICS]
LIST_SUBTABLES = []
@ -32,35 +33,6 @@ UNIQUE_FIELDS = [FIELD_NAME]
IDENTIFYER_FIELDS = [FIELD_ID]
""" unique technical field as technical identifer """
STEP_ATTR_NR = "nr"
""" unique number in test-specification / in comp the array-position """
STEP_ATTR_GROUP = "step"
""" step-number in test-specification / in comp the block itself """
STEP_ATTR_COMP = "comp"
""" comp-name which executes the step """
STEP_ATTR_FCT = "fct"
""" fct-name which executes the step in the component """
STEP_ATTR_TOOL_TYPE = "type"
""" interface of the tool, values cli, dbi """
STEP_ATTR_TOOL_NAME = "type"
""" name of the tool, values cli, dbi """
STEP_ATTR_ARGS = "args"
LIST_STEP_ATTR = [STEP_ATTR_NR, STEP_ATTR_GROUP, STEP_ATTR_COMP, STEP_ATTR_FCT,
STEP_ATTR_TOOL_TYPE, STEP_ATTR_TOOL_NAME, STEP_ATTR_ARGS]
FIELDS = {
STEP_ATTR_NR : "nr",
STEP_ATTR_GROUP : "group",
STEP_ATTR_COMP : "comp",
STEP_ATTR_FCT : "fct",
STEP_ATTR_TOOL_TYPE : "tool",
STEP_ATTR_TOOL_NAME : "toolname",
STEP_ATTR_ARGS : "args"
}
# step
# testsuite | testcase | component
#---------------------------------- # ---------------------------------- # ----------------------------------
# start programs # start function #
class Step(model.entity.Entity):
"""
@ -79,13 +51,12 @@ class Step(model.entity.Entity):
variant = ""
sortnr = 0
""" sorting, alternative step may have the same sortnr, then the correct step is selected by program-variant """
progstep = 0
stepnr = 0
""" in order to filter the steps for specific program-executions """
dataref = ""
component = "" # the name of the component or of the parameter "testcases"
arguments = {}
topic = "" # is set by component-configuration
type = "" # is set by component-configuration
attributes = {}
topics = "" # is set by component-configuration
def __init__(self, job, project="", name="", obj=None):
"""
@ -101,10 +72,6 @@ class Step(model.entity.Entity):
self.project = project
if len(name) > 1:
self.name = name
if obj is not None:
self.setEntity(LIST_STEP_ATTR, name, obj)
else:
self.getEntity(job, name)
def read_unique_names(self, job, project, application, gran, args):
"""
@ -143,10 +110,36 @@ class Step(model.entity.Entity):
print(str(comp))
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.variant
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return "{:02d}_{}".format(int(self.sortnr), self.variant)

26
model/story.py

@ -69,10 +69,36 @@ class Story(model.entity.Entity):
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name

26
model/table.py

@ -147,14 +147,40 @@ class Table(model.entity.Entity):
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name
def read_ddl(self, job, name):
ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, self.component, name)
self.fieldnames = []

41
model/testcase.py

@ -32,14 +32,14 @@ FIELD_NAME = D.FIELD_NAME
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT]
FIELD_APPLICATION = B.SUBJECT_APP
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_APPLICATION,
FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT]
""" list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES]
SUB_USECASE = B.SUBJECT_USECASES
SUB_STORIES = B.SUBJECT_STORIES
SUB_VARIANTS = B.SUBJECT_VARIANTS
SUB_APPLICATIONS = B.SUBJECT_APPS
SUB_STEPS = "steps"
SUB_TABLES = "tables"
LIST_SUBTABLES = {
@ -47,8 +47,6 @@ LIST_SUBTABLES = {
SUB_STEPS: [],
SUB_USECASE: [B.SUBJECT_DESCRIPTION, B.SUBJECT_REFERENCE],
SUB_STORIES: [B.SUBJECT_DESCRIPTION, B.SUBJECT_REFERENCE],
SUB_APPLICATIONS: [],
SUB_VARIANTS: []
}
LIST_SUB_DESCRIPT = [D.DATA_ATTR_USECASE_DESCR, D.DATA_ATTR_STORY_DESCR]
@ -75,13 +73,10 @@ class Testcase(model.entity.Entity):
description = ""
project = ""
reference = ""
attributes = ""
attribute = ""
stories = {}
docs = []
tables = {}
steps = {}
applications = {}
variants = {}
def __init__(self, job, project, name=""):
"""
@ -121,18 +116,44 @@ class Testcase(model.entity.Entity):
"""
# r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001")
config = self.getConfig(job, P.KEY_TESTCASE, name, tools.config_tool.get_plain_filename(job, name))
self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES)
self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
return self
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name
def xxread_entity(self, job, name):
"""
reads the entity from the file-system

26
model/testplan.py

@ -50,10 +50,36 @@ class Testplan(model.entity.Entity):
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name

26
model/testsuite.py

@ -105,14 +105,40 @@ class Testsuite(model.entity.Entity):
return self
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name
def get_schema(self, tableName="", tableObject=None):
#TODO veraltet
dbtype = self.job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE]

26
model/topic.py

@ -63,10 +63,36 @@ class Topic(model.entity.Entity):
config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, "")
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name

26
model/usecase.py

@ -72,10 +72,36 @@ class Usecase(model.entity.Entity):
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name

26
model/user.py

@ -113,14 +113,40 @@ class User(model.entity.Entity):
return self
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name
def select_entity(self, job, name, row={}):
"""
reads the entity from the database

26
model/variant.py

@ -79,10 +79,36 @@ class Variant(model.entity.Entity):
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
"""
returns a list of scalar attributes
:return: LIST_FIELDS
"""
return LIST_FIELDS
def getNodeList(self):
"""
returns a list of sub-nodes - which can be persisted in a clob-field
:return: LIST_NODES
"""
return LIST_NODES
def getSubtableList(self):
"""
returns a list of sub-tables
:return: LIST_SUBTABLES
"""
return LIST_SUBTABLES
def getName(self):
"""
returns the name - maybe build from other attributes
:return:
"""
return self.name
def getIDName(self):
"""
it returns the name as unique-id - maybe build from few attributes
:return:
"""
return self.name

4
test/test_27testcase.py

@ -65,10 +65,6 @@ class MyTestCase(unittest.TestCase):
acttestcase = testcase.read_entity(job, name)
self.assertEqual(getattr(acttestcase, model.testcase.FIELD_NAME), name)
self.assertRaises(Exception, testcase.read_entity, job, "xyzxyz")
#
#actrelease = release.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name)
#self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"])
if __name__ == '__main__':
unittest.main()

15
tools/data_tool.py

@ -76,3 +76,18 @@ def getStrDict(invalue):
kv = x.split(":")
outDict[kv[0].replace("\"", "")] = kv[1].replace("\"", "")
return outDict
def getValueStr(invalue):
if isinstance(invalue, dict):
keys = list(invalue.keys())
if len(keys) == 0:
return ""
if len(keys) >= 1:
return keys[0]
if isinstance(invalue, list):
if len(invalue) == 0:
return ""
if len(invalue) >= 1:
return invalue[0]
return invalue

13
tools/filecsv_fcts.py

@ -15,6 +15,8 @@ from basic import toolHandling
import traceback
import tools.data_tool
DEFAULT_TTYPE = D.CSV_SPECTYPE_DATA
class FileFcts(tools.file_abstract.FileFcts):
def __init__(self):
@ -161,10 +163,13 @@ class FileFcts(tools.file_abstract.FileFcts):
if verbose: print(">> tables " + l)
h = a
h[0] = B.DATA_NODE_TABLES
if ttype in ["", "csv"]:
ttype = DEFAULT_TTYPE
if ttype == D.CSV_SPECTYPE_CONF:
del h[0]
tableDict = getTdataContent(msg, tdata, h)
setTableHeader(tableDict, tableAttr, fields, ttype, job)
tableDict[tools.data_tool.getSingularAttribut(D.FIELD_NAME)] = h[-1]
status = D.CSV_SPECTYPE_DATA
# table-data-Block
elif (status == D.CSV_SPECTYPE_DATA):
@ -175,7 +180,7 @@ class FileFcts(tools.file_abstract.FileFcts):
# step-data-Block
elif (status == D.CSV_BLOCK_STEP):
if verify: print("block "+D.CSV_BLOCK_STEP+"2 :: "+l)
print("step-line "+status+": "+l)
if verify: print("step-line "+status+": "+l)
#h = []
steps = setStepAttribute(job, steps, fields[1], fields)
tdata[B.SUBJECT_STEPS] = steps
@ -396,13 +401,14 @@ def setSubTable(job, subtable, key, val):
:param val:
:return:
"""
verify = False
# stories => new subtable
# stories-descriptiom => attribute of actual subtable
# descriptiom => attribute of actual subtable
key = key.lower() # tools.data_tool.getPluralKeyword(key)
subkey = ""
newSubtable = False
print("setSubtable "+key+", "+str(val))
if verify: print("setSubtable "+key+", "+str(val))
if "actTable" in subtable and subtable["actTable"]+"-" in key:
subkey = key[key.find("-")+1:]
keyword = tools.data_tool.getPluralKeyword(key)
@ -412,7 +418,7 @@ def setSubTable(job, subtable, key, val):
subtable["actTable"] = keyword
actTable = subtable["actTable"]
purKey = tools.data_tool.getPurKeyword(key)
print("setSubtable "+key+" =? "+actTable+ " + "+ purKey +" , "+str(val))
if verify: print("setSubtable "+key+" =? "+actTable+ " + "+ purKey +" , "+str(val))
actKeys = list(subtable[actTable].keys())
for i in range(1, len(val)):
if newSubtable and val[i] not in subtable[actTable]:
@ -496,6 +502,7 @@ def setTdataContent(msg, data, tabledata, path):
data[path[0]][path[1]][path[2]] = tabledata
elif len(path) == 4:
data[path[0]][path[1]][path[2]][path[3]] = tabledata
data[tools.data_tool.getSingularAttribut(D.FIELD_NAME)] = path[-1]
def setTdataStructure(msg, data, path):
if len(path) >= 1 and path[0] not in data:

Loading…
Cancel
Save