Browse Source

refactoring: basic-model - with objects

refactor
Ulrich 1 year ago
parent
commit
e65ebcbccc
  1. 47
      model/datatable.py
  2. 32
      model/entity.py
  3. 126
      model/factory.py
  4. 50
      model/step.py
  5. 202
      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 = {}
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
document = ""
description = ""
project = ""
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=""):
"""
@ -58,37 +55,3 @@ class Datatable(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

32
model/entity.py

@ -63,10 +63,10 @@ class Entity:
LIST_SUBTABLES = []
PREFIX_SUBTABLE = ""
def __init__(self, job, name=""):
def __init__(self, job, name: str="", args: dict={}):
self.job = job
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=""):
"""
@ -153,13 +153,28 @@ class Entity:
config[B.DATA_NODE_DDL][t] = ddl
setattr(self, "conf", config)
def getEntity(self, job, name):
if B.TOPIC_NODE_DB in job.conf:
def getEntity(self, job, name: str, args: dict={}):
if len(args) > 0:
self.set_entity(job, name, args)
elif B.TOPIC_NODE_DB in job.conf:
self.select_entity(job, name)
#self.read_entity(job, name)
else:
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):
"""
reads the entity from the file-system
@ -355,8 +370,11 @@ class Entity:
verify = False
if not job is None:
self.job = job
try:
if rootname not in config:
return self
except:
pass
for k in fields + nodes:
key = tools.data_tool.getExistKeyword(k, config[rootname])
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]:
continue
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]))
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
if verify: print("setSubtables " + k + " = " + str(objects))
setattr(self, k, objects)

126
model/factory.py

@ -3,101 +3,101 @@ import basic.constants as B
import basic.Testserver
def get_entity_object(job, name, args):
if name in [B.SUBJECT_STEPS, B.SUBJECT_STEP]:
entity = getStep(job)
elif name in [B.SUBJECT_STORIES, B.SUBJECT_STORY, "storys"]:
entity = getStory(job)
elif name in [B.SUBJECT_VARIANTS, B.SUBJECT_VARIANT]:
entity = getVariant(job)
elif name in [B.SUBJECT_DATATABLES, B.SUBJECT_DATATABLE]:
entity = getDatatable(job)
elif name in [B.SUBJECT_USECASES, B.SUBJECT_USECASE]:
entity = getUsecase(job)
elif name in [B.SUBJECT_PROJECTS, B.SUBJECT_PROJECT]:
entity = getProject(job)
elif name in [B.SUBJECT_APPS, B.SUBJECT_APP]:
entity = getApplication(job)
elif name in [B.SUBJECT_COMPS, B.SUBJECT_COMP]:
entity = getComponent(job)
elif name in [B.SUBJECT_ARTIFACTS, B.SUBJECT_ARTIFACT]:
entity = getEnvironment(job)
elif name in [B.SUBJECT_TESTCASES, B.SUBJECT_TESTCASE]:
entity = getTestcase(job)
elif name in [B.SUBJECT_TESTSUITES, B.SUBJECT_TESTSUITE]:
entity = getTestsuite(job)
elif name in [B.SUBJECT_TESTPLANS, B.SUBJECT_TESTPLAN]:
entity = getTestplan(job)
elif name in [B.SUBJECT_USERS, B.SUBJECT_USER]:
entity = getUser(job)
elif name in [B.SUBJECT_REL, B.SUBJECT_RELS]:
entity = getRelease(job)
elif name in [B.SUBJECT_ENVIRONMENT, B.SUBJECT_ENVIRONMENTS]:
entity = getEnvironment(job)
def get_entity_object(job, entityname: str, name: str="", args: dict={}):
if entityname in [B.SUBJECT_STEPS, B.SUBJECT_STEP]:
entity = getStep(job, name, args)
elif entityname in [B.SUBJECT_STORIES, B.SUBJECT_STORY, "storys"]:
entity = getStory(job, name, args)
elif entityname in [B.SUBJECT_VARIANTS, B.SUBJECT_VARIANT]:
entity = getVariant(job, name, args)
elif entityname in [B.SUBJECT_DATATABLES, B.SUBJECT_DATATABLE]:
entity = getDatatable(job, name, args)
elif entityname in [B.SUBJECT_USECASES, B.SUBJECT_USECASE]:
entity = getUsecase(job, name, args)
elif entityname in [B.SUBJECT_PROJECTS, B.SUBJECT_PROJECT]:
entity = getProject(job, name, args)
elif entityname in [B.SUBJECT_APPS, B.SUBJECT_APP]:
entity = getApplication(job, name, args)
elif entityname in [B.SUBJECT_COMPS, B.SUBJECT_COMP]:
entity = getComponent(job, name, args)
elif entityname in [B.SUBJECT_ARTIFACTS, B.SUBJECT_ARTIFACT]:
entity = getEnvironment(job, name, args)
elif entityname in [B.SUBJECT_TESTCASES, B.SUBJECT_TESTCASE]:
entity = getTestcase(job, name, args)
elif entityname in [B.SUBJECT_TESTSUITES, B.SUBJECT_TESTSUITE]:
entity = getTestsuite(job, name, args)
elif entityname in [B.SUBJECT_TESTPLANS, B.SUBJECT_TESTPLAN]:
entity = getTestplan(job, name, args)
elif entityname in [B.SUBJECT_USERS, B.SUBJECT_USER]:
entity = getUser(job, name, args)
elif entityname in [B.SUBJECT_REL, B.SUBJECT_RELS]:
entity = getRelease(job, name, args)
elif entityname in [B.SUBJECT_ENVIRONMENT, B.SUBJECT_ENVIRONMENTS]:
entity = getEnvironment(job, name, args)
else:
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)
return entity
def getRelease(job=None, name=""):
def getRelease(job=None, name: str="", args: dict={}):
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
* 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
variant = ""
sortnr = 0
@ -60,21 +68,6 @@ class Step(model.entity.Entity):
attributes = {}
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=""):
"""
reads the entity-names from file-storage
@ -111,33 +104,6 @@ class Step(model.entity.Entity):
comp = cm.getComponent(variant["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):
"""

202
model/testcase.py

@ -5,7 +5,10 @@
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import os
import traceback
import basic.toolHandling
import tools.data_tool
import tools.job_const as J
import tools.data_const as D
import basic.constants as B
@ -50,10 +53,10 @@ class Testcase(model.entity.Entity):
tables -> comp.table
"""
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]
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 = ""
name = ""
@ -106,152 +109,93 @@ class Testcase(model.entity.Entity):
"""
data = tools.file_type.popSubjectsNode(job, data)
# data = tools.file_type.popNameNode(job, data)
data = Testcase.buildHeadAttributes(job, data, Testcase.LIST_FIELDS, Testcase.LIST_SUBTABLES)
return data
@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
:param job:
:param tdata:
workaround for _head:attr resp _option:attr
:param data:
:param head:
:return:
"""
outData = {}
subtables = {}
arguments = {}
for k in tdata:
if k in [B.DATA_NODE_TABLES]:
outData[k[1:]] = tdata[k]
elif k in [B.DATA_NODE_OPTION, "_head"]:
outData[k[1:]] = {}
for e in tdata[k]:
ka = str(e).split("-")
if ka[0] in B.LIST_SUBJECTS:
# not necceassary, because here are single-names with fieldname
ka[0] = ka[0][:-1]
if len(ka) == 1:
# add reference name to potential subtable
ka.append("name")
if ka[0]+"s" in B.LIST_SUBJECTS:
# standard table form: step: { _header: [], _data: [{}, {}, ..] }
if ka[0] in subtables:
subject = subtables[ka[0]]
sublist = subject[B.DATA_NODE_DATA]
header = subject[B.DATA_NODE_HEADER]
outdata = {}
attributes = {}
subtable = {}
xsubtable = {}
try:
for k in data:
if k in [B.DATA_NODE_HEAD, B.DATA_NODE_OPTION]:
if k not in outdata:
outdata[k] = {}
xkeys = []
for l in data[k]:
a = l.split("-")
val = data[k][l]
if tools.data_tool.getPluralKeyword(a[0]) in B.LIST_SUBJECTS \
and tools.data_tool.getSingularKeyword(a[0]) in fields:
outdata[tools.data_tool.getSingularKeyword(a[0])] = tools.data_tool.splitDelimitedValues(val)[0]
elif tools.data_tool.getPluralKeyword(a[0]) in B.LIST_SUBJECTS \
and tools.data_tool.getPluralKeyword(a[0]) in subtables:
xsubtable = Testcase.setSubtable(job, xsubtable, l, val, outdata)
#outdata[tools.data_tool.getPluralKeyword(a[0])] = subtable
elif k == B.DATA_NODE_OPTION:
attributes[l] = data[k][l]
else:
enty = model.factory.get_entity_object(job, ka[0], {})
header = enty.getFieldList() + enty.getNodeList()
sublist = []
subject = {}
subject[B.DATA_NODE_DATA] = sublist
subject[B.DATA_NODE_HEADER] = header
#subtables[ka[0]]
string = str(tdata[k][e])
values = str(tdata[k][e]).split(D.INTERNAL_DELIMITER)
i = 0
for v in values:
if len(v) < 1:
continue
if len(sublist) > i:
subtable = sublist[i]
outdata[k][l] = data[k][l]
elif k in B.LIST_DATA_NODE and tools.data_tool.getPluralKeyword(k) in subtables:
outdata[tools.data_tool.getPluralKeyword(k)] = data[k]
else:
outdata[k] = data[k]
if len(outdata[B.DATA_NODE_OPTION]) == 0:
outdata.pop(B.DATA_NODE_OPTION)
if len(outdata[B.DATA_NODE_HEAD]) == 0:
outdata.pop(B.DATA_NODE_HEAD)
outdata[B.NODE_ATTRIBUTES] = attributes
for k in xsubtable:
if k == "xkeys":
continue
outdata[k] = xsubtable[k]
except Exception as e:
print(traceback.format_exc())
pass
return outdata
@staticmethod
def setSubtable(job, xsubtable, key: str, val: str, data: dict):
a = key.split("-")
if tools.data_tool.getPluralKeyword(a[0]) not in xsubtable:
xkeys = []
subtable = {}
sublist.append(subtable)
subtable[ka[1]] = v
sublist[i] = subtable
i += 1
subject[B.DATA_NODE_DATA] = sublist
subtables[ka[0]] = subject
else: # attributes
arguments[e] = tdata[k][e]
elif k in B.SUBJECT_STORY:
outData[B.SUBJECT_STORIES] = tdata[k]
elif k in B.LIST_SUBJECTS:
outData[k] = tdata[k]
elif k in B.LIST_DATA_NODE:
outData[k[1:]] = tdata[k]
elif k[1:] in Testcase.LIST_FIELDS:
outData[k[1:]] = tdata[k]
for x in tools.data_tool.splitDelimitedValues(val):
if x == "" or x[:1] == "#": break
subtable[x] = {D.FIELD_NAME: x}
xkeys.append(x)
else:
raise Exception("unknown tag in csv-data: "+k)
for s in subtables:
outData[s] = subtables[s]
outData[B.NODE_ATTRIBUTES] = arguments
return outData
subtable = xsubtable[tools.data_tool.getPluralKeyword(a[0])]
i = 0
vals = tools.data_tool.splitDelimitedValues(val)
xkeys = xsubtable["xkeys"]
for x in xkeys:
subtable[x][a[1]] = vals[i]
i += 1
xsubtable["xkeys"] = xkeys
xsubtable[tools.data_tool.getPluralKeyword(a[0])] = subtable
return xsubtable
@staticmethod
def check_data(job, data: dict) -> dict:
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]
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]
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):
"""
reads the entity from the database
@ -260,7 +204,7 @@ class Testcase(model.entity.Entity):
:param name:
:return:
"""
raise Exception(B.EXCEPT_NOT_IMPLEMENT)
return self.read_entity(job, name)
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'}
res = tools.job_tool.select_variant(job, "", "Testfall", args)
print(str(res))
self.assertEqual(3, len(res))
self.assertEqual("01_init_testcase", res[0])
self.assertEqual(2, len(res))
self.assertEqual("xml-rest", res[0])
args = {'proc': 'Testfall ausfuehren', 'gran': 'Testfall', 'user': 'ulrich',
'project': 'TESTPROJ', 'step': '1', 'program': 'test_executer',
'application': 'TESTAPP', 'environment': 'ENV01', 'testcase': 'TC0001'}
res = tools.job_tool.select_variant(job, "", "Testfall", args)
print(str(res))
self.assertEqual(3, len(res))
self.assertEqual("01_init_testcase", res[0])
self.assertEqual(2, len(res))
self.assertEqual("xml-rest", res[0])
def test_14selectTestplan(self):
global mymsg

2
tools/data_const.py

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

16
tools/data_tool.py

@ -1,5 +1,5 @@
import basic.constants as B
import tools.data_const as D
def getPurKeyword(inkey):
"""
@ -23,19 +23,31 @@ def getPurKeyword(inkey):
return keyPur
def getPluralKeyword(inkey):
if "story" in inkey:
return B.SUBJECT_STORIES
return getPurKeyword(inkey)+"s"
def getSingularKeyword(inkey):
if inkey == "stories":
if "stories" in inkey:
return B.SUBJECT_STORY
return getPurKeyword(inkey)
def getPluralAttribut(inkey):
if "story" in inkey:
return "_"+B.SUBJECT_STORIES
return "_"+getPurKeyword(inkey)+"s"
def getSingularAttribut(inkey):
if "stories" in inkey:
return "_"+B.SUBJECT_STORY
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):
"""
returns the existing keyword in the dictionary

18
tools/file_type.py

@ -173,6 +173,12 @@ class DatatypeCatalog():
return data
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:
key = list(data.keys())[0]
if key in B.LIST_SUBJECTS:
@ -180,6 +186,12 @@ def popSubjectsNode(job, data: dict) -> dict:
return data
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:
return data
outdata = {}
@ -204,6 +216,12 @@ def popTablesNode(job, data: dict) -> dict:
return outdata
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 = {}
for k in data:
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]:
setParameterArgs(job, args, [B.PAR_PROJ])
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):
outVariants = list(getattr(testsuite, B.SUBJECT_VARIANTS).keys())
elif gran in [B.PAR_TESTCASE, J.GRAN_TC]:
setParameterArgs(job, args, [B.PAR_PROJ])
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))
#if "variant" not in testcase:
# return [""]

Loading…
Cancel
Save