Browse Source

refactoring: basic-model - with objects

refactor
Ulrich 1 year ago
parent
commit
e65ebcbccc
  1. 47
      model/datatable.py
  2. 36
      model/entity.py
  3. 126
      model/factory.py
  4. 50
      model/step.py
  5. 208
      model/testcase.py
  6. 8
      test/test_10job.py
  7. 2
      tools/data_const.py
  8. 16
      tools/data_tool.py
  9. 18
      tools/file_type.py
  10. 6
      tools/job_tool.py

47
model/datatable.py

@ -24,20 +24,17 @@ LIST_NODES = [B.DATA_NODE_HEADER, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS]
LIST_SUBTABLES = {} LIST_SUBTABLES = {}
class Datatable(model.entity.Entity): class Datatable(model.entity.Entity):
FIELD_ID = "dtid"
LIST_FIELDS = [FIELD_ID, D.FIELD_NAME, B.SUBJECT_DESCRIPTION, B.SUBJECT_REFERENCE, B.SUBJECT_COMP, B.NODE_ATTRIBUTES]
LIST_NODES = [B.DATA_NODE_HEADER, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS]
LIST_SUBTABLES = []
dcid = 0 dcid = 0
document = "" document = ""
description = "" description = ""
project = "" project = ""
reference = "" reference = ""
def __init__(self, job, project="", name=""):
"""
to be initialized by readSpec
:param job:
"""
self.job = job
if project != "":
self.project = project
def read_unique_names(self, job, project, application, gran, args, ttype: str=""): def read_unique_names(self, job, project, application, gran, args, ttype: str=""):
""" """
@ -58,37 +55,3 @@ class Datatable(model.entity.Entity):
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 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

36
model/entity.py

@ -63,10 +63,10 @@ class Entity:
LIST_SUBTABLES = [] LIST_SUBTABLES = []
PREFIX_SUBTABLE = "" PREFIX_SUBTABLE = ""
def __init__(self, job, name=""): def __init__(self, job, name: str="", args: dict={}):
self.job = job self.job = job
if len(name) > 1: if len(name) > 1:
self.getEntity(job, name) self.getEntity(job, name, args)
def get_unique_names(self, job, storage="", project="", application="", gran="", args={}, ttype: str=""): def get_unique_names(self, job, storage="", project="", application="", gran="", args={}, ttype: str=""):
""" """
@ -153,13 +153,28 @@ class Entity:
config[B.DATA_NODE_DDL][t] = ddl config[B.DATA_NODE_DDL][t] = ddl
setattr(self, "conf", config) setattr(self, "conf", config)
def getEntity(self, job, name): def getEntity(self, job, name: str, args: dict={}):
if B.TOPIC_NODE_DB in job.conf: if len(args) > 0:
self.set_entity(job, name, args)
elif B.TOPIC_NODE_DB in job.conf:
self.select_entity(job, name) self.select_entity(job, name)
#self.read_entity(job, name) #self.read_entity(job, name)
else: else:
self.read_entity(job, name) self.read_entity(job, name)
def set_entity(self, job, name: str, args: dict):
setattr(self, D.FIELD_NAME, name)
for k in self.LIST_FIELDS:
if k in args:
setattr(self, k, args[k])
for k in self.LIST_SUBTABLES:
if k in args:
setattr(self, k, args[k])
for k in self.LIST_NODES:
if k in args:
setattr(self, k, args[k])
def read_entity(self, job, name): def read_entity(self, job, name):
""" """
reads the entity from the file-system reads the entity from the file-system
@ -355,8 +370,11 @@ class Entity:
verify = False verify = False
if not job is None: if not job is None:
self.job = job self.job = job
if rootname not in config: try:
return self if rootname not in config:
return self
except:
pass
for k in fields + nodes: for k in fields + nodes:
key = tools.data_tool.getExistKeyword(k, config[rootname]) key = tools.data_tool.getExistKeyword(k, config[rootname])
if verify: print("setFields " + k + " / " + key) if verify: print("setFields " + k + " / " + key)
@ -385,9 +403,11 @@ class Entity:
if o in [B.DATA_NODE_DATA, B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_ROW, B.DATA_NODE_PATH]: if o in [B.DATA_NODE_DATA, B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_ROW, B.DATA_NODE_PATH]:
continue continue
args = {} args = {}
args[k] = config[rootname][key][o] for x in config[rootname][key][o]:
args[x] = config[rootname][key][o][x]
# args[k] = config[rootname][key][o]
if verify: print("setSubObject " + o + " = " + str(args[k])) if verify: print("setSubObject " + o + " = " + str(args[k]))
object = model.factory.get_entity_object(self.job, k, args) object = model.factory.get_entity_object(self.job, entityname=k, name=o, args=args)
objects[object.getIDName()] = object objects[object.getIDName()] = object
if verify: print("setSubtables " + k + " = " + str(objects)) if verify: print("setSubtables " + k + " = " + str(objects))
setattr(self, k, objects) setattr(self, k, objects)

126
model/factory.py

@ -3,101 +3,101 @@ import basic.constants as B
import basic.Testserver import basic.Testserver
def get_entity_object(job, name, args): def get_entity_object(job, entityname: str, name: str="", args: dict={}):
if name in [B.SUBJECT_STEPS, B.SUBJECT_STEP]: if entityname in [B.SUBJECT_STEPS, B.SUBJECT_STEP]:
entity = getStep(job) entity = getStep(job, name, args)
elif name in [B.SUBJECT_STORIES, B.SUBJECT_STORY, "storys"]: elif entityname in [B.SUBJECT_STORIES, B.SUBJECT_STORY, "storys"]:
entity = getStory(job) entity = getStory(job, name, args)
elif name in [B.SUBJECT_VARIANTS, B.SUBJECT_VARIANT]: elif entityname in [B.SUBJECT_VARIANTS, B.SUBJECT_VARIANT]:
entity = getVariant(job) entity = getVariant(job, name, args)
elif name in [B.SUBJECT_DATATABLES, B.SUBJECT_DATATABLE]: elif entityname in [B.SUBJECT_DATATABLES, B.SUBJECT_DATATABLE]:
entity = getDatatable(job) entity = getDatatable(job, name, args)
elif name in [B.SUBJECT_USECASES, B.SUBJECT_USECASE]: elif entityname in [B.SUBJECT_USECASES, B.SUBJECT_USECASE]:
entity = getUsecase(job) entity = getUsecase(job, name, args)
elif name in [B.SUBJECT_PROJECTS, B.SUBJECT_PROJECT]: elif entityname in [B.SUBJECT_PROJECTS, B.SUBJECT_PROJECT]:
entity = getProject(job) entity = getProject(job, name, args)
elif name in [B.SUBJECT_APPS, B.SUBJECT_APP]: elif entityname in [B.SUBJECT_APPS, B.SUBJECT_APP]:
entity = getApplication(job) entity = getApplication(job, name, args)
elif name in [B.SUBJECT_COMPS, B.SUBJECT_COMP]: elif entityname in [B.SUBJECT_COMPS, B.SUBJECT_COMP]:
entity = getComponent(job) entity = getComponent(job, name, args)
elif name in [B.SUBJECT_ARTIFACTS, B.SUBJECT_ARTIFACT]: elif entityname in [B.SUBJECT_ARTIFACTS, B.SUBJECT_ARTIFACT]:
entity = getEnvironment(job) entity = getEnvironment(job, name, args)
elif name in [B.SUBJECT_TESTCASES, B.SUBJECT_TESTCASE]: elif entityname in [B.SUBJECT_TESTCASES, B.SUBJECT_TESTCASE]:
entity = getTestcase(job) entity = getTestcase(job, name, args)
elif name in [B.SUBJECT_TESTSUITES, B.SUBJECT_TESTSUITE]: elif entityname in [B.SUBJECT_TESTSUITES, B.SUBJECT_TESTSUITE]:
entity = getTestsuite(job) entity = getTestsuite(job, name, args)
elif name in [B.SUBJECT_TESTPLANS, B.SUBJECT_TESTPLAN]: elif entityname in [B.SUBJECT_TESTPLANS, B.SUBJECT_TESTPLAN]:
entity = getTestplan(job) entity = getTestplan(job, name, args)
elif name in [B.SUBJECT_USERS, B.SUBJECT_USER]: elif entityname in [B.SUBJECT_USERS, B.SUBJECT_USER]:
entity = getUser(job) entity = getUser(job, name, args)
elif name in [B.SUBJECT_REL, B.SUBJECT_RELS]: elif entityname in [B.SUBJECT_REL, B.SUBJECT_RELS]:
entity = getRelease(job) entity = getRelease(job, name, args)
elif name in [B.SUBJECT_ENVIRONMENT, B.SUBJECT_ENVIRONMENTS]: elif entityname in [B.SUBJECT_ENVIRONMENT, B.SUBJECT_ENVIRONMENTS]:
entity = getEnvironment(job) entity = getEnvironment(job, name, args)
else: else:
return None return None
entity.setAttributes(job, args, name, entity.getFieldList(), entity.getNodeList(), entity.getSubtableList()) #entity.setAttributes(job, args, name, entity.getFieldList(), entity.getNodeList(), entity.getSubtableList())
#testserver = basic.Testserver.getInstance(job) #testserver = basic.Testserver.getInstance(job)
return entity return entity
def getRelease(job=None, name=""): def getRelease(job=None, name: str="", args: dict={}):
import model.release import model.release
return model.release.Release(job) return model.release.Release(job, name, args)
def getEnvironment(job=None, name=""): def getEnvironment(job=None, name: str="", args: dict={}):
import model.environment import model.environment
return model.environment.Environment(job) return model.environment.Environment(job, name, args)
def getArtifact(job=None, name=""): def getArtifact(job=None, name: str="", args: dict={}):
import model.artifact import model.artifact
return model.artifact.Artifact(job) return model.artifact.Artifact(job, name, args)
def getApplication(job=None, args={}, name=""): def getApplication(job=None, name: str="", args: dict={}):
import model.application import model.application
return model.application.Application(job) return model.application.Application(job, name, args)
def getProject(job=None, name=""): def getProject(job=None, name: str="", args: dict={}):
import model.project import model.project
return model.project.Project(job) return model.project.Project(job, name, args)
def getComponent(job=None, name=""): def getComponent(job=None, name: str="", args: dict={}):
import model.component import model.component
return model.component.Component(job) return model.component.Component(job, name, args)
def getTestplan(job=None, project="", application="", name=""): def getTestplan(job=None, name: str="", args: dict={}):
import model.testplan import model.testplan
return model.testplan.Testplan(job, project) return model.testplan.Testplan(job, name, args)
def getTestsuite(job=None, name="", project="", application=""): def getTestsuite(job=None, name: str="", args: dict={}):
import model.testsuite import model.testsuite
return model.testsuite.Testsuite(job, name) return model.testsuite.Testsuite(job, name, args)
def getTestcase(job=None, project="", application="", name=""): def getTestcase(job=None, name: str="", args: dict={}):
import model.testcase import model.testcase
return model.testcase.Testcase(job, name) return model.testcase.Testcase(job, name, args)
def getStep(job=None, project="", name=""): def getStep(job=None, name: str="", args: dict={}):
import model.step import model.step
return model.step.Step(job, project, name) return model.step.Step(job, name, args)
def getStory(job=None, project="", name=""): def getStory(job=None, name: str="", args: dict={}):
import model.story import model.story
return model.story.Story(job, name) return model.story.Story(job, name, args)
def getUsecase(job=None, project="", name=""): def getUsecase(job=None, name: str="", args: dict={}):
import model.usecase import model.usecase
return model.usecase.Usecase(job, name) return model.usecase.Usecase(job, name, args)
def getUser(job=None, project="", name=""): def getUser(job=None, name: str="", args: dict={}):
import model.user import model.user
return model.user.User(job, name) return model.user.User(job, name, args)
def getVariant(job=None, project="", name=""): def getVariant(job=None, name: str="", args: dict={}):
import model.variant import model.variant
return model.variant.Variant(job, name) return model.variant.Variant(job, name, args)
def getDatatable(job=None, project="", name=""): def getDatatable(job=None, name: str="", args: dict={}):
import model.datatable import model.datatable
return model.datatable.Datatable(job, project, name) return model.datatable.Datatable(job, name, args)

50
model/step.py

@ -49,6 +49,14 @@ class Step(model.entity.Entity):
* topic and type which implements the detail-step * topic and type which implements the detail-step
* further arguments inside the dict * further arguments inside the dict
""" """
FIELD_ID = "spid"
FIELD_SORTNR = "sortnr" # testcase
FIELD_STEPNR = "stepnr" # testcase
FIELD_DATAREF = "dataref" # testcase
LIST_FIELDS = [FIELD_ID, D.FIELD_NAME, B.SUBJECT_VARIANT, B.SUBJECT_COMP, FIELD_SORTNR, FIELD_STEPNR, FIELD_DATAREF]
""" list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES, B.DATA_NODE_TOPICS]
LIST_SUBTABLES = []
name = "" # variant name = "" # variant
variant = "" variant = ""
sortnr = 0 sortnr = 0
@ -60,21 +68,6 @@ class Step(model.entity.Entity):
attributes = {} attributes = {}
topics = "" # is set by component-configuration topics = "" # is set by component-configuration
def __init__(self, job, project="", name="", obj=None):
"""
to be initialized by readSpec
project : optional
alternative parameter
name : name of variant or default - only from testspec
obj : object with main attributes
:param job:
"""
self.job = job
if len(project) > 1:
self.project = project
if len(name) > 1:
self.name = name
def read_unique_names(self, job, project, application, gran, args, ttype: str=""): def read_unique_names(self, job, project, application, gran, args, ttype: str=""):
""" """
reads the entity-names from file-storage reads the entity-names from file-storage
@ -111,33 +104,6 @@ class Step(model.entity.Entity):
comp = cm.getComponent(variant["comp"]) comp = cm.getComponent(variant["comp"])
print(str(comp)) 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): def getIDName(self):
""" """

208
model/testcase.py

@ -5,7 +5,10 @@
# Source : gitea.ucarmesin.de # Source : gitea.ucarmesin.de
# --------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------
import os import os
import traceback
import basic.toolHandling import basic.toolHandling
import tools.data_tool
import tools.job_const as J import tools.job_const as J
import tools.data_const as D import tools.data_const as D
import basic.constants as B import basic.constants as B
@ -50,10 +53,10 @@ class Testcase(model.entity.Entity):
tables -> comp.table tables -> comp.table
""" """
FIELD_ID = "tcid" FIELD_ID = "tcid"
LIST_FIELDS = [FIELD_ID, D.FIELD_NAME, B.SUBJECT_APPS, LIST_FIELDS = [FIELD_ID, D.FIELD_NAME, B.SUBJECT_APP,
B.SUBJECT_DESCRIPTION, B.SUBJECT_REFERENCE, B.SUBJECT_PROJECT] B.SUBJECT_DESCRIPTION, B.SUBJECT_REFERENCE, B.SUBJECT_PROJECT]
LIST_NODES = [B.NODE_ATTRIBUTES] LIST_NODES = [B.NODE_ATTRIBUTES]
LIST_SUBTABLES = [B.SUBJECT_USECASES, B.SUBJECT_STEPS, B.SUBJECT_DATATABLES, B.SUBJECT_STEPS] LIST_SUBTABLES = [B.SUBJECT_VARIANTS, B.SUBJECT_USECASES, B.SUBJECT_STORIES, B.SUBJECT_DATATABLES, B.SUBJECT_STEPS]
tcid = "" tcid = ""
name = "" name = ""
@ -106,152 +109,93 @@ class Testcase(model.entity.Entity):
""" """
data = tools.file_type.popSubjectsNode(job, data) data = tools.file_type.popSubjectsNode(job, data)
# data = tools.file_type.popNameNode(job, data) # data = tools.file_type.popNameNode(job, data)
data = Testcase.buildHeadAttributes(job, data, Testcase.LIST_FIELDS, Testcase.LIST_SUBTABLES)
return data return data
@staticmethod @staticmethod
def oldrebuild_data(job, tdata: dict) -> dict: def buildHeadAttributes(job, data: dict, fields: list, subtables: list) -> dict:
""" """
gets the subtable-tag from filecsv and sets the subtables in order to workable entity-elements workaround for _head:attr resp _option:attr
:param job: :param data:
:param tdata: :param head:
:return: :return:
""" """
outData = {}
subtables = {} outdata = {}
arguments = {} attributes = {}
for k in tdata: subtable = {}
if k in [B.DATA_NODE_TABLES]: xsubtable = {}
outData[k[1:]] = tdata[k] try:
elif k in [B.DATA_NODE_OPTION, "_head"]: for k in data:
outData[k[1:]] = {} if k in [B.DATA_NODE_HEAD, B.DATA_NODE_OPTION]:
for e in tdata[k]: if k not in outdata:
ka = str(e).split("-") outdata[k] = {}
if ka[0] in B.LIST_SUBJECTS: xkeys = []
# not necceassary, because here are single-names with fieldname for l in data[k]:
ka[0] = ka[0][:-1] a = l.split("-")
if len(ka) == 1: val = data[k][l]
# add reference name to potential subtable if tools.data_tool.getPluralKeyword(a[0]) in B.LIST_SUBJECTS \
ka.append("name") and tools.data_tool.getSingularKeyword(a[0]) in fields:
if ka[0]+"s" in B.LIST_SUBJECTS: outdata[tools.data_tool.getSingularKeyword(a[0])] = tools.data_tool.splitDelimitedValues(val)[0]
# standard table form: step: { _header: [], _data: [{}, {}, ..] } elif tools.data_tool.getPluralKeyword(a[0]) in B.LIST_SUBJECTS \
if ka[0] in subtables: and tools.data_tool.getPluralKeyword(a[0]) in subtables:
subject = subtables[ka[0]] xsubtable = Testcase.setSubtable(job, xsubtable, l, val, outdata)
sublist = subject[B.DATA_NODE_DATA] #outdata[tools.data_tool.getPluralKeyword(a[0])] = subtable
header = subject[B.DATA_NODE_HEADER] elif k == B.DATA_NODE_OPTION:
attributes[l] = data[k][l]
else: else:
enty = model.factory.get_entity_object(job, ka[0], {}) outdata[k][l] = data[k][l]
header = enty.getFieldList() + enty.getNodeList() elif k in B.LIST_DATA_NODE and tools.data_tool.getPluralKeyword(k) in subtables:
sublist = [] outdata[tools.data_tool.getPluralKeyword(k)] = data[k]
subject = {} else:
subject[B.DATA_NODE_DATA] = sublist outdata[k] = data[k]
subject[B.DATA_NODE_HEADER] = header if len(outdata[B.DATA_NODE_OPTION]) == 0:
#subtables[ka[0]] outdata.pop(B.DATA_NODE_OPTION)
string = str(tdata[k][e]) if len(outdata[B.DATA_NODE_HEAD]) == 0:
values = str(tdata[k][e]).split(D.INTERNAL_DELIMITER) outdata.pop(B.DATA_NODE_HEAD)
i = 0 outdata[B.NODE_ATTRIBUTES] = attributes
for v in values: for k in xsubtable:
if len(v) < 1: if k == "xkeys":
continue continue
if len(sublist) > i: outdata[k] = xsubtable[k]
subtable = sublist[i] except Exception as e:
else: print(traceback.format_exc())
subtable = {} pass
sublist.append(subtable) return outdata
subtable[ka[1]] = v
sublist[i] = subtable @staticmethod
i += 1 def setSubtable(job, xsubtable, key: str, val: str, data: dict):
subject[B.DATA_NODE_DATA] = sublist a = key.split("-")
subtables[ka[0]] = subject if tools.data_tool.getPluralKeyword(a[0]) not in xsubtable:
else: # attributes xkeys = []
arguments[e] = tdata[k][e] subtable = {}
elif k in B.SUBJECT_STORY: for x in tools.data_tool.splitDelimitedValues(val):
outData[B.SUBJECT_STORIES] = tdata[k] if x == "" or x[:1] == "#": break
elif k in B.LIST_SUBJECTS: subtable[x] = {D.FIELD_NAME: x}
outData[k] = tdata[k] xkeys.append(x)
elif k in B.LIST_DATA_NODE: else:
outData[k[1:]] = tdata[k] subtable = xsubtable[tools.data_tool.getPluralKeyword(a[0])]
elif k[1:] in Testcase.LIST_FIELDS: i = 0
outData[k[1:]] = tdata[k] vals = tools.data_tool.splitDelimitedValues(val)
else: xkeys = xsubtable["xkeys"]
raise Exception("unknown tag in csv-data: "+k) for x in xkeys:
for s in subtables: subtable[x][a[1]] = vals[i]
outData[s] = subtables[s] i += 1
outData[B.NODE_ATTRIBUTES] = arguments xsubtable["xkeys"] = xkeys
return outData xsubtable[tools.data_tool.getPluralKeyword(a[0])] = subtable
return xsubtable
@staticmethod @staticmethod
def check_data(job, data: dict) -> dict: def check_data(job, data: dict) -> dict:
checkNodes = {} checkNodes = {}
checkNodes[tools.file_type.MUST_NODES] = [B.SUBJECT_APP, B.SUBJECT_DATATABLES, B.SUBJECT_STEPS, checkNodes[tools.file_type.MUST_NODES] = [B.SUBJECT_APP, B.SUBJECT_DATATABLES, B.SUBJECT_STEPS, B.SUBJECT_VARIANTS,
B.NODE_ATTRIBUTES] B.NODE_ATTRIBUTES]
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.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_USECASES, B.SUBJECT_STORIES] checkNodes[tools.file_type.OPT_NODES] = [B.SUBJECT_USECASES, B.SUBJECT_STORIES]
return tools.file_type.check_nodes(job, data, checkNodes) return tools.file_type.check_nodes(job, data, checkNodes)
def xxread_entity(self, job, name):
"""
reads the entity from the file-system
:param job:
:param name:
:return:
"""
pathname = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, name, "")
print(pathname)
(fname, ext) = os.path.splitext(pathname)
fi = basic.toolHandling.getFileTool(job, None, ext[1:])
tdata = fi.load_file(pathname, ttype=D.CSV_SPECTYPE_DATA)
stories = []
docs = []
attributes = {}
pass
if B.DATA_NODE_HEAD in tdata:
for h in D.LIST_HEAD_ATTR:
if h in tdata[B.DATA_NODE_HEAD]:
setattr(self, h, tdata[B.DATA_NODE_HEAD][h])
else:
job.m.logWarn("Keine Head-Daten in Testcase "+name)
if B.DATA_NODE_OPTION in tdata:
for o in tdata[B.DATA_NODE_OPTION]:
if o in [D.OPT_ATTR_UCID, D.OPT_ATTR_USECASE]:
pass
elif o in [D.OPT_ATTR_STORYID, D.OPT_ATTR_STORY]:
if len(stories) < 1:
story = model.story.Story(job)
stories.append(story)
else:
story = stories[0]
setattr(story, model.story.FIELDS[o], tdata[B.DATA_NODE_OPTION][o])
elif o in D.LIST_OPT_ATTR:
setattr(self, o, tdata[B.DATA_NODE_OPTION][o])
else:
attributes[o] = tdata[B.DATA_NODE_OPTION][o]
else:
job.m.logWarn("Keine Option-Daten in Testcase "+name)
if len(attributes) > 0:
self.attributes = attributes
if len(stories) > 0:
self.story = stories
pass
if B.DATA_NODE_STEPS in tdata:
for s in tdata[B.DATA_NODE_STEPS]:
if s in B.LIST_DATA_NODE:
continue
step = model.step.Step(job, project=job.par.project, name=s)
pass
if B.DATA_NODE_TABLES in tdata:
for t in tdata[B.DATA_NODE_TABLES]:
table = model.datatable.Datatable(job, project=job.par.project, name=t)
pass
# for o in tdata[B.option
# header = tdata[B.DATA_NODE_STEPS][] LIST
# reference
#
# for t in tdata[B.tables
#raise Exception(B.EXCEPT_NOT_IMPLEMENT)
def select_entity(self, job, name): def select_entity(self, job, name):
""" """
reads the entity from the database reads the entity from the database
@ -260,7 +204,7 @@ class Testcase(model.entity.Entity):
:param name: :param name:
:return: :return:
""" """
raise Exception(B.EXCEPT_NOT_IMPLEMENT) return self.read_entity(job, name)
def select_testcase(job, project, testcase): def select_testcase(job, project, testcase):

8
test/test_10job.py

@ -118,15 +118,15 @@ class MyTestCase(unittest.TestCase):
'application': 'TESTAPP', 'environment': 'ENV01', 'testcase': 'TC0002'} 'application': 'TESTAPP', 'environment': 'ENV01', 'testcase': 'TC0002'}
res = tools.job_tool.select_variant(job, "", "Testfall", args) res = tools.job_tool.select_variant(job, "", "Testfall", args)
print(str(res)) print(str(res))
self.assertEqual(3, len(res)) self.assertEqual(2, len(res))
self.assertEqual("01_init_testcase", res[0]) self.assertEqual("xml-rest", res[0])
args = {'proc': 'Testfall ausfuehren', 'gran': 'Testfall', 'user': 'ulrich', args = {'proc': 'Testfall ausfuehren', 'gran': 'Testfall', 'user': 'ulrich',
'project': 'TESTPROJ', 'step': '1', 'program': 'test_executer', 'project': 'TESTPROJ', 'step': '1', 'program': 'test_executer',
'application': 'TESTAPP', 'environment': 'ENV01', 'testcase': 'TC0001'} 'application': 'TESTAPP', 'environment': 'ENV01', 'testcase': 'TC0001'}
res = tools.job_tool.select_variant(job, "", "Testfall", args) res = tools.job_tool.select_variant(job, "", "Testfall", args)
print(str(res)) print(str(res))
self.assertEqual(3, len(res)) self.assertEqual(2, len(res))
self.assertEqual("01_init_testcase", res[0]) self.assertEqual("xml-rest", res[0])
def test_14selectTestplan(self): def test_14selectTestplan(self):
global mymsg global mymsg

2
tools/data_const.py

@ -158,7 +158,7 @@ CSV_SPECTYPE_COMP = "comp"
CSV_NODETYPE_KEYS = "_keys" CSV_NODETYPE_KEYS = "_keys"
CSV_BLOCK_ATTR = "_attr" CSV_BLOCK_ATTR = "_attr"
CSV_BLOCK_HEAD = "_head" CSV_BLOCK_HEAD = B.DATA_NODE_HEAD
CSV_BLOCK_OPTION = B.DATA_NODE_OPTION CSV_BLOCK_OPTION = B.DATA_NODE_OPTION
CSV_BLOCK_STEP = B.DATA_NODE_STEPS CSV_BLOCK_STEP = B.DATA_NODE_STEPS
CSV_BLOCK_TABLES = "_table" CSV_BLOCK_TABLES = "_table"

16
tools/data_tool.py

@ -1,5 +1,5 @@
import basic.constants as B import basic.constants as B
import tools.data_const as D
def getPurKeyword(inkey): def getPurKeyword(inkey):
""" """
@ -23,19 +23,31 @@ def getPurKeyword(inkey):
return keyPur return keyPur
def getPluralKeyword(inkey): def getPluralKeyword(inkey):
if "story" in inkey:
return B.SUBJECT_STORIES
return getPurKeyword(inkey)+"s" return getPurKeyword(inkey)+"s"
def getSingularKeyword(inkey): def getSingularKeyword(inkey):
if inkey == "stories": if "stories" in inkey:
return B.SUBJECT_STORY return B.SUBJECT_STORY
return getPurKeyword(inkey) return getPurKeyword(inkey)
def getPluralAttribut(inkey): def getPluralAttribut(inkey):
if "story" in inkey:
return "_"+B.SUBJECT_STORIES
return "_"+getPurKeyword(inkey)+"s" return "_"+getPurKeyword(inkey)+"s"
def getSingularAttribut(inkey): def getSingularAttribut(inkey):
if "stories" in inkey:
return "_"+B.SUBJECT_STORY
return "_"+getPurKeyword(inkey) return "_"+getPurKeyword(inkey)
def splitDelimitedValues(inValue: str):
return inValue.split(D.INTERNAL_DELIMITER)
def joinValues(inValues: list):
return D.INTERNAL_DELIMITER.join(inValues)
def getExistKeyword(inkey, inDict): def getExistKeyword(inkey, inDict):
""" """
returns the existing keyword in the dictionary returns the existing keyword in the dictionary

18
tools/file_type.py

@ -173,6 +173,12 @@ class DatatypeCatalog():
return data return data
def popSubjectsNode(job, data: dict) -> dict: def popSubjectsNode(job, data: dict) -> dict:
"""
it shifts the single main-tree above the node subjects to the top in order to get the main-tree on the top.
:param job:
:param data:
:return:
"""
if len(data) == 1: if len(data) == 1:
key = list(data.keys())[0] key = list(data.keys())[0]
if key in B.LIST_SUBJECTS: if key in B.LIST_SUBJECTS:
@ -180,6 +186,12 @@ def popSubjectsNode(job, data: dict) -> dict:
return data return data
def popTablesNode(job, data: dict) -> dict: def popTablesNode(job, data: dict) -> dict:
"""
it shifts the single main-tree above the node _tables to the top in order to get the main-tree on the top.
:param job:
:param data:
:return:
"""
if B.DATA_NODE_TABLES not in data: if B.DATA_NODE_TABLES not in data:
return data return data
outdata = {} outdata = {}
@ -204,6 +216,12 @@ def popTablesNode(job, data: dict) -> dict:
return outdata return outdata
def popNameNode(job, data: dict) -> dict: def popNameNode(job, data: dict) -> dict:
"""
it shifts the single main-tree above the node name at the top in order to get the main-tree at the top.
:param job:
:param data:
:return:
"""
outdata = {} outdata = {}
for k in data: for k in data:
if "_"+D.FIELD_NAME in data[k] and k == data[k]["_"+D.FIELD_NAME]: if "_"+D.FIELD_NAME in data[k] and k == data[k]["_"+D.FIELD_NAME]:

6
tools/job_tool.py

@ -283,13 +283,15 @@ def select_variant(job, programDef, gran, args):
elif gran in [B.PAR_TESTSUITE, J.GRAN_TS]: elif gran in [B.PAR_TESTSUITE, J.GRAN_TS]:
setParameterArgs(job, args, [B.PAR_PROJ]) setParameterArgs(job, args, [B.PAR_PROJ])
print("select ts spec " + gran) print("select ts spec " + gran)
testsuite = model.factory.getTestsuite(job, args[B.PAR_PROJ], name=args[B.PAR_TESTSUITE]) testsuite = model.factory.getTestsuite(job, name=args[B.PAR_TESTSUITE])
testsuite = testsuite.read_entity(job, name=args[B.PAR_TESTSUITE])
if hasattr(testsuite, B.SUBJECT_VARIANTS): if hasattr(testsuite, B.SUBJECT_VARIANTS):
outVariants = list(getattr(testsuite, B.SUBJECT_VARIANTS).keys()) outVariants = list(getattr(testsuite, B.SUBJECT_VARIANTS).keys())
elif gran in [B.PAR_TESTCASE, J.GRAN_TC]: elif gran in [B.PAR_TESTCASE, J.GRAN_TC]:
setParameterArgs(job, args, [B.PAR_PROJ]) setParameterArgs(job, args, [B.PAR_PROJ])
print("select tc spec " + gran + " " + str(args)) print("select tc spec " + gran + " " + str(args))
testcase = model.factory.getTestcase(job, args[B.PAR_PROJ], name=args[B.PAR_TESTCASE]) testcase = model.factory.getTestcase(job, name=args[B.PAR_TESTCASE])
testcase = testcase.read_entity(job, name=args[B.PAR_TESTCASE])
print(str(testcase)) print(str(testcase))
#if "variant" not in testcase: #if "variant" not in testcase:
# return [""] # return [""]

Loading…
Cancel
Save