Browse Source

read and setAttributes for entities

refactor
Ulrich 1 year ago
parent
commit
8d9df0feb6
  1. 7
      basic/constants.py
  2. 13
      model/application.py
  3. 0
      model/datatable.csv
  4. 42
      model/datatable.py
  5. 20
      model/document.py
  6. 62
      model/entity.py
  7. 3
      model/environment.py
  8. 43
      model/factory.py
  9. 11
      model/release.py
  10. 45
      model/step.py
  11. 13
      model/story.py
  12. 14
      model/table.py
  13. 30
      model/testcase.py
  14. 34
      model/testplan.py
  15. 11
      model/testsuite.py
  16. 72
      model/topic.py
  17. 11
      model/usecase.py
  18. 11
      model/user.py
  19. 11
      model/variant.py
  20. 122
      test/test_14entity.py
  21. 1
      tools/data_const.py
  22. 19
      tools/data_tool.py
  23. 2
      tools/filecsv_fcts.py

7
basic/constants.py

@ -156,7 +156,7 @@ topics relating to the domain are:
SUBJECT_PROJECT = "project" SUBJECT_PROJECT = "project"
SUBJECT_PROJECTS = SUBJECT_PROJECT + "s" SUBJECT_PROJECTS = SUBJECT_PROJECT + "s"
SUBJECT_APP = "application" SUBJECT_APP = "application"
SUBJECT_APPS = "applications" # SUBJECT_APPS = SUBJECT_APP+"s" #
SUBJECT_COMP = "component" SUBJECT_COMP = "component"
SUBJECT_COMPS = SUBJECT_COMP + "s" SUBJECT_COMPS = SUBJECT_COMP + "s"
SUBJECT_USECASE = "usecase" SUBJECT_USECASE = "usecase"
@ -195,6 +195,8 @@ SUBJECT_REFERENCE = "reference" # --> MAIN-ATTR
LIST_SUBJECTS = [SUBJECT_APPS, SUBJECT_ARTIFACT, SUBJECT_COMPS, SUBJECT_PROJECTS] LIST_SUBJECTS = [SUBJECT_APPS, SUBJECT_ARTIFACT, SUBJECT_COMPS, SUBJECT_PROJECTS]
SUBJECT_STEP = "step" SUBJECT_STEP = "step"
SUBJECT_STEPS = "steps" SUBJECT_STEPS = "steps"
SUBJECT_DATATABLE = "table"
SUBJECT_DATATABLES = SUBJECT_DATATABLE + "s"
# --Topic ----------------------------------------------------- # --Topic -----------------------------------------------------
# _____ _ # _____ _
@ -335,7 +337,8 @@ DATA_NODE_PAR = "par"
DATA_NODE_CATALOG = "_catalog" DATA_NODE_CATALOG = "_catalog"
DATA_NODE_ROW = "_row" DATA_NODE_ROW = "_row"
DATA_NODE_SUBTABLES = "subtables" # ?? SUBJECT DATA_NODE_SUBTABLES = "subtables" # ?? SUBJECT
LIST_DATA_NODE = [DATA_NODE_HEADER, DATA_NODE_DATA, DATA_NODE_DDL, DATA_NODE_TOPICS = "_topics"
LIST_DATA_NODE = [DATA_NODE_HEADER, DATA_NODE_DATA, DATA_NODE_DDL, DATA_NODE_TOPICS,
DATA_NODE_TABLES, DATA_NODE_STEPS, DATA_NODE_OPTION, DATA_NODE_ROW] DATA_NODE_TABLES, DATA_NODE_STEPS, DATA_NODE_OPTION, DATA_NODE_ROW]
# -- Parameter ------------------------------------------------ # -- Parameter ------------------------------------------------

13
model/application.py

@ -29,6 +29,7 @@ FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT FIELD_PROJECT = B.SUBJECT_PROJECT
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT]
""" list of object-attributes """ """ list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES]
SUB_COMPS = B.SUBJECT_COMPS SUB_COMPS = B.SUBJECT_COMPS
SUB_APPS = B.SUBJECT_APPS SUB_APPS = B.SUBJECT_APPS
@ -263,7 +264,17 @@ class Application(model.entity.Entity):
:return: :return:
""" """
config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS, tools.config_tool.get_plain_filename(job, name)) config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES
class Application_old(model.entity.Entity): class Application_old(model.entity.Entity):
table = "application" table = "application"

0
model/table.csv → model/datatable.csv

1 table:table _field type format index generic aggregat key acceptance alias description
2 tbid pk integer N T:1
3 name str vchar(256) I F:1
4 description string vchar(256) N
5 reference str vchar(256) N story
6 attributes jlob clob N
7 insauthor str vchar(256) N
8 inscommit str vchar(256) N
9 instime time datetime N
10 updauthor str vchar(256) N
11 updcommit str vchar(256) N
12 updtime time datetime N
13 actual int integer I

42
model/datatable.py

@ -0,0 +1,42 @@
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import basic.constants as B
import model.entity
FIELD_ID = "dtid"
FIELD_NAME = "name"
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_COMPONENT = B.SUBJECT_COMP
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
FIELD_HEADER = ""
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_COMPONENT]
LIST_NODES = [B.DATA_NODE_HEADER, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS]
LIST_SUBTABLES = {}
class Datatable(model.entity.Entity):
dcid = 0
document = ""
description = ""
project = ""
reference = ""
def __init__(self, job, project="", name=""):
"""
to be initialized by readSpec
:param job:
"""
self.job = job
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES

20
model/document.py

@ -1,20 +0,0 @@
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import basic.constants as B
import model.entity
class Document(model.entity.Entity):
dcid = 0
document = ""
description = ""
project = ""
reference = ""
def __init__(self, job, project="", name=""):
"""
to be initialized by readSpec
:param job:
"""
self.job = job

62
model/entity.py

@ -2,11 +2,13 @@ import getpass
import os import os
import re import re
import basic.toolHandling import basic.toolHandling
import model.factory
# import model.entity # import model.entity
import tools.data_const as D import tools.data_const as D
import tools.path_const as P import tools.path_const as P
import basic.constants as B import basic.constants as B
import tools.config_tool import tools.config_tool
import tools.data_tool
import tools.date_tool import tools.date_tool
import tools.file_tool import tools.file_tool
@ -297,32 +299,56 @@ class Entity:
outList.append(k[:-len(ext)-1]) outList.append(k[:-len(ext)-1])
return outList return outList
def setAttributes(self, config, rootname, fields, subjects): def setAttributes(self, job, config, rootname, fields, nodes, subjects):
"""
it sets the attributes of config into the entity-object
:param job:
:param config: dictionary of readed specification resp. configuration
:param rootname: rootname of config
:param fields: list of field-names, the model-const LIST_FIELDS
:param nodes: list of node-names, the model-const LIST_NODES
:param subjects: list of subtables-names, the model-const LIST_SUBTABLES
:return:
"""
setattr(self, D.FIELD_NAME, rootname)
""" 2023-05 """ """ 2023-05 """
for k in fields: for k in fields + nodes:
if k not in config[rootname]: key = tools.data_tool.getExistKeyword(k, config[rootname])
for l in config[rootname]: if key in ["", D.FIELD_NAME, D.FIELD_PROJECT]:
if l[1:] == k:
setattr(self, k, config[rootname][l])
break
continue continue
setattr(self, k, config[rootname][k]) setattr(self, k, config[rootname][key])
for k in subjects: for k in subjects:
if k not in config[rootname]: objects = {}
for l in config[rootname]: key = tools.data_tool.getExistKeyword(k, config[rootname])
if l[1:] == k: if key == "":
setattr(self, k, config[rootname][l])
break
continue continue
setattr(self, k, config[rootname][k]) for o in config[rootname][key]:
args = {}
args[k] = config[rootname][key][o]
objects[o] = model.factory.get_entity_object(self.job, k, args)
setattr(self, k, objects)
topics = {} topics = {}
key = tools.data_tool.getExistKeyword(B.DATA_NODE_TOPICS, config[rootname])
if key != "":
for k in B.LIST_TOPIC_NODES: for k in B.LIST_TOPIC_NODES:
if k in config[rootname]: if k in config[rootname][key]:
topics[k] = config[rootname][k] topics[k] = config[rootname][key][k]
if len(topics) > 0: setattr(self, tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS), topics)
setattr(self, "topics", topics)
return self return self
def getFieldList(self):
return []
def getNodeList(self):
return []
def getSubtableList(self):
return {}
def setSubtable(self, job, subtable, sublist):
outDict = {}
for k in sublist:
pass
def getDbAttr(self, job): def getDbAttr(self, job):
out = {} out = {}

3
model/environment.py

@ -22,6 +22,7 @@ FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_ATTRIBUTES] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_ATTRIBUTES]
""" list of object-attributes """ """ list of object-attributes """
LIST_SUBTABLES = [B.SUBJECT_COMPS, B.SUBJECT_PROJECTS] LIST_SUBTABLES = [B.SUBJECT_COMPS, B.SUBJECT_PROJECTS]
LIST_NODES = [B.NODE_ATTRIBUTES]
FILE_EXTENSION = D.DFILE_TYPE_YML FILE_EXTENSION = D.DFILE_TYPE_YML
UNIQUE_FIELDS = [FIELD_NAME] UNIQUE_FIELDS = [FIELD_NAME]
@ -104,5 +105,5 @@ class Environment(model.entity.Entity):
:return: :return:
""" """
config = self.getConfig(job, P.KEY_ENV, name, tools.config_tool.get_plain_filename(job, name)) config = self.getConfig(job, P.KEY_ENV, name, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)

43
model/factory.py

@ -1,5 +1,27 @@
import model.entity import model.entity
import basic.constants as B
def get_entity_object(job, name, args):
if name in B.SUBJECT_STEPS:
entity = getStep(job)
elif name in B.SUBJECT_STORIES:
entity = getStory(job)
elif name in B.SUBJECT_VARIANTS:
entity = getVariant(job)
elif name in B.SUBJECT_DATATABLES:
entity = getDatatable(job)
elif name in B.SUBJECT_APPS:
entity = getApplication(job)
elif name in B.SUBJECT_COMPS:
entity = getComponent(job)
elif name in B.SUBJECT_TESTCASES:
entity = getTestcase(job)
elif name in B.SUBJECT_TESTSUITES:
entity = getTestsuite(job)
else:
return None
entity.setAttributes(job, args, name, entity.getFieldList(), entity.getNodeList(), entity.getSubtableList())
return entity
def getEnvironment(job=None): def getEnvironment(job=None):
import model.environment import model.environment
@ -24,3 +46,24 @@ def getTestsuite(job=None, project="", application="", name=""):
def getTestcase(job=None, project="", application="", name=""): def getTestcase(job=None, project="", application="", name=""):
import model.testcase import model.testcase
return model.testcase.Testcase(job, project, name=name) return model.testcase.Testcase(job, project, name=name)
def getStep(job=None, project="", name=""):
import model.step
return model.step.Step(job, project, name)
def getStory(job=None, project="", name=""):
import model.story
return model.story.Story(job, project, name)
def getUsecase(job=None, project="", name=""):
import model.usecase
return model.usecase.Usecase(job, project, name)
def getVariant(job=None, project="", name=""):
import model.variant
return model.variant.Variant(job, project, name)
def getDatatable(job=None, project="", name=""):
import model.datatable
return model.datatable.Datatable(job, project, name)

11
model/release.py

@ -23,6 +23,7 @@ FIELD_APPLICATION = B.SUBJECT_APP
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_APPLICATION, FIELD_ATTRIBUTES] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_APPLICATION, FIELD_ATTRIBUTES]
""" list of object-attributes """ """ list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES]
LIST_SUBTABLES = [] LIST_SUBTABLES = []
FILE_EXTENSION = D.DFILE_TYPE_CSV FILE_EXTENSION = D.DFILE_TYPE_CSV
@ -70,5 +71,13 @@ class Release(model.entity.Entity):
:return: :return:
""" """
config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_RELS, tools.config_tool.get_plain_filename(job, name)) config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_RELS, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES

45
model/step.py

@ -23,6 +23,7 @@ FIELD_COMPONENT = B.SUBJECT_COMP
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_COMPONENT] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_COMPONENT]
""" list of object-attributes """ """ list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES, B.DATA_NODE_TOPICS]
LIST_SUBTABLES = [] LIST_SUBTABLES = []
FILE_EXTENSION = D.DFILE_TYPE_YML FILE_EXTENSION = D.DFILE_TYPE_YML
@ -62,16 +63,29 @@ FIELDS = {
# start programs # start function # # start programs # start function #
class Step(model.entity.Entity): class Step(model.entity.Entity):
nr = 0 """
name = "" this class describes execution steps in a formal language = fields,
description = "" in testcase-specification it describe the start-point of an action, here the business information are specified like
project = "" * variant
group = 0 * reference of program-step, sorting-nr, reference to testdata which are specified above
component = "" * entity which implements the action
fct = "" * further business-arguments as json-string
tool = "" the detailed steps (build the request, send the request, get the response, ..) are configured in the component
toolname = "" in sub-steps of the specified step, here the technical information are configured like
args = {} * topic and type which implements the detail-step
* further arguments inside the dict
"""
name = "" # variant
variant = ""
sortnr = 0
""" sorting, alternative step may have the same sortnr, then the correct step is selected by program-variant """
progstep = 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
def __init__(self, job, project="", name="", obj=None): def __init__(self, job, project="", name="", obj=None):
""" """
@ -114,7 +128,7 @@ class Step(model.entity.Entity):
: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))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def rest_read(self, job, name): def rest_read(self, job, name):
print("step read "+name) print("step read "+name)
@ -127,3 +141,12 @@ class Step(model.entity.Entity):
cm = basic.componentHandling.ComponentManager.getInstance(job) cm = basic.componentHandling.ComponentManager.getInstance(job)
comp = cm.getComponent(variant["comp"]) comp = cm.getComponent(variant["comp"])
print(str(comp)) print(str(comp))
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES

13
model/story.py

@ -20,7 +20,8 @@ FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_ATTRIBUTES] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_ATTRIBUTES]
""" list of object-attributes """ """ list of object-attributes """
LIST_SUBTABLES = [] LIST_NODES = [B.NODE_ATTRIBUTES]
LIST_SUBTABLES = {}
FILE_EXTENSION = D.DFILE_TYPE_CSV FILE_EXTENSION = D.DFILE_TYPE_CSV
UNIQUE_FIELDS = [FIELD_NAME] UNIQUE_FIELDS = [FIELD_NAME]
@ -65,5 +66,13 @@ class Story(model.entity.Entity):
:return: :return:
""" """
config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_STORIES, tools.config_tool.get_plain_filename(job, name)) config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_STORIES, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES

14
model/table.py

@ -23,8 +23,9 @@ FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_APPLICATION = B.SUBJECT_APP FIELD_APPLICATION = B.SUBJECT_APP
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE]
""" list of object-attributes """ """ list of object-attributes """
LIST_NODES = [B.DATA_NODE_HEADER, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS]
LIST_SUBTABLES = [] LIST_SUBTABLES = {}
DEFAULT_FIELD = "" DEFAULT_FIELD = ""
DEFAULT_TYPE = "string" DEFAULT_TYPE = "string"
@ -143,7 +144,16 @@ class Table(model.entity.Entity):
def read_entity(self, job, name): def read_entity(self, job, name):
config = self.getConfig(job, P.KEY_CATALOG, name, tools.config_tool.get_plain_filename(job, name)) config = self.getConfig(job, P.KEY_CATALOG, name, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES
def read_ddl(self, job, name): def read_ddl(self, job, name):
ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, self.component, name) ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, self.component, name)

30
model/testcase.py

@ -16,7 +16,7 @@ import tools.path_tool
import tools.path_const as P import tools.path_const as P
import model.entity import model.entity
import model.story import model.story
import model.document import model.datatable
import model.step import model.step
import model.table import model.table
@ -34,6 +34,7 @@ FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT FIELD_PROJECT = B.SUBJECT_PROJECT
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT]
""" list of object-attributes """ """ list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES]
SUB_USECASE = B.SUBJECT_USECASES SUB_USECASE = B.SUBJECT_USECASES
SUB_STORIES = B.SUBJECT_STORIES SUB_STORIES = B.SUBJECT_STORIES
@ -121,26 +122,17 @@ class Testcase(model.entity.Entity):
# r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001") # 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)) 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(config, name, LIST_FIELDS, LIST_SUBTABLES)
"""
for k in LIST_SUBTABLES.keys():
if not hasattr(self, k):
continue
pass
if "_"+k in config[name] and "_"+k+"-description" in LIST_SUB_DESCRIPT:
values = {}
if "_"+k+"-description" in config[name]:
for l in config[name]["_"+k]:
if l in config[name]["_"+k+"-description"]:
values[config[name]["_"+k][l]] = config[name]["_" + k + "-description"][l]
else:
values[config[name]["_"+k][l]] = ""
else:
for l in config[name]["_"+k]:
values[config[name]["_" + k][l]] = ""
setattr(self, k, values)
"""
return self return self
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES
def xxread_entity(self, job, name): def xxread_entity(self, job, name):
""" """
reads the entity from the file-system reads the entity from the file-system

34
model/testplan.py

@ -8,6 +8,22 @@ import basic.toolHandling
import tools.data_const as D import tools.data_const as D
import basic.constants as B import basic.constants as B
import model.entity import model.entity
import tools.config_tool
FIELD_ID = "tcid"
FIELD_NAME = D.FIELD_NAME
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_RELEASE = B.SUBJECT_REL
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_RELEASE]
""" list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES]
LIST_SUBTABLES = {
B.SUBJECT_STEPS: [],
B.SUBJECT_TESTSUITES: []
}
class Testplan(model.entity.Entity): class Testplan(model.entity.Entity):
name = "" name = ""
@ -23,3 +39,21 @@ class Testplan(model.entity.Entity):
""" """
self.job = job self.job = job
def read_entity(self, job, name):
"""
reads the entity from the file-system
:param job:
:param name:
:return:
"""
config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES

11
model/testsuite.py

@ -28,6 +28,7 @@ FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT FIELD_PROJECT = B.SUBJECT_PROJECT
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT]
""" list of object-attributes """ """ list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES]
SUB_USECASE = B.SUBJECT_USECASES SUB_USECASE = B.SUBJECT_USECASES
SUB_TESTCASES = B.SUBJECT_TESTCASES SUB_TESTCASES = B.SUBJECT_TESTCASES
@ -85,7 +86,7 @@ class Testsuite(model.entity.Entity):
""" """
# r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001") # r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001")
config = self.getConfig(job, P.KEY_TESTSUITE, name, tools.config_tool.get_plain_filename(job, name)) config = self.getConfig(job, P.KEY_TESTSUITE, name, tools.config_tool.get_plain_filename(job, name))
self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) #self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES)
for k in LIST_SUBTABLES: for k in LIST_SUBTABLES:
if not hasattr(self, k): if not hasattr(self, k):
continue continue
@ -103,6 +104,14 @@ class Testsuite(model.entity.Entity):
setattr(self, k, values) setattr(self, k, values)
return self return self
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES
def get_schema(self, tableName="", tableObject=None): def get_schema(self, tableName="", tableObject=None):
#TODO veraltet #TODO veraltet

72
model/topic.py

@ -0,0 +1,72 @@
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
"""
spontanes Fliegengewicht, das aus einer der folgenden Contexte gebodlet wird.
step:
hier als umzusetzende Technik
artefact:
hier als umzusetzende Technik bei init oder collect
component:
als Superklasse zwecks Ererben fehlernder Attribute
environment:
als Superklasse zwecks Ererben fehlernder Attribute
in den jeweiligen technischen Elternklassenv werden die Attribute gesammelt und bei der Ausfuehrung komprimmiert.
Die so zusammen gesammelten Konfigurationen werden der jeweilgen Funktionsklasse uebergeben.
"""
import os
import basic.constants as B
import model.entity
import tools.path_const as P
import tools.data_tool
import tools.data_const as D
TABLE_NAME = tools.data_tool.getSingularKeyword(B.DATA_NODE_TOPICS)
""" system-name for this entity """
FIELD_ID = "toid"
FIELD_NAME = D.FIELD_NAME
LIST_FIELDS = [FIELD_ID, FIELD_NAME]
""" list of object-attributes """
LIST_NODES = []
LIST_SUBTABLES = {}
component = ""
environment = ""
topic = "" #
""" one of B.LIST_TOPIC_NODES """
type = "" #
""" one of the implemented Tools """
class Topic(model.entity.Entity):
name = ""
type = ""
attributes = ""
environment = ""
component = ""
def __init__(self, job, environment, component, name=""):
"""
to be initialized by readSpec
"""
self.job = job
self.environment = environment
self.component = component
def read_entity(self, job, name):
"""
reads the entity from the file-system
:param job:
:param name:
:return:
"""
config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, "")
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES

11
model/usecase.py

@ -21,6 +21,7 @@ FIELD_APPLICATION = B.SUBJECT_APP
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_APPLICATION, FIELD_ATTRIBUTES] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_APPLICATION, FIELD_ATTRIBUTES]
""" list of object-attributes """ """ list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES]
LIST_SUBTABLES = [] LIST_SUBTABLES = []
FILE_EXTENSION = D.DFILE_TYPE_CSV FILE_EXTENSION = D.DFILE_TYPE_CSV
@ -68,5 +69,13 @@ class Usecase(model.entity.Entity):
:return: :return:
""" """
config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_USECASES, tools.config_tool.get_plain_filename(job, name)) config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_USECASES, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES

11
model/user.py

@ -25,6 +25,8 @@ FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_ROLE = "role" FIELD_ROLE = "role"
LIST_FIELDS = [FIELD_ID, FIELD_ROLE, FIELD_PROJECT, FIELD_PASSWORD, FIELD_EMAIL, FIELD_FAMNAME, FIELD_NAME, FIELD_USERNAME] LIST_FIELDS = [FIELD_ID, FIELD_ROLE, FIELD_PROJECT, FIELD_PASSWORD, FIELD_EMAIL, FIELD_FAMNAME, FIELD_NAME, FIELD_USERNAME]
""" list of object-attributes """ """ list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES]
LIST_SUBTABLES = {}
FILE_EXTENSION = D.DFILE_TYPE_YML FILE_EXTENSION = D.DFILE_TYPE_YML
UNIQUE_FIELDS = [FIELD_USERNAME] UNIQUE_FIELDS = [FIELD_USERNAME]
@ -110,6 +112,15 @@ class User(model.entity.Entity):
setattr(self, k, config[k]) setattr(self, k, config[k])
return self return self
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES
def select_entity(self, job, name, row={}): def select_entity(self, job, name, row={}):
""" """
reads the entity from the database reads the entity from the database

11
model/variant.py

@ -24,6 +24,7 @@ FIELD_COMPONENT = B.SUBJECT_COMP
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_COMPONENT, FIELD_ATTRIBUTES] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_COMPONENT, FIELD_ATTRIBUTES]
""" list of object-attributes """ """ list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES]
LIST_SUBTABLES = [] LIST_SUBTABLES = []
FILE_EXTENSION = D.DFILE_TYPE_YML FILE_EXTENSION = D.DFILE_TYPE_YML
@ -75,5 +76,13 @@ class Variant(model.entity.Entity):
: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))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
return LIST_FIELDS
def getNodeList(self):
return LIST_NODES
def getSubtableList(self):
return LIST_SUBTABLES

122
test/test_14entity.py

@ -0,0 +1,122 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import unittest
import inspect
import test.testtools
import basic.constants as B
import test.constants as T
import model.testcase
import model.entity
import tools.data_tool
HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10setAttributes"]
TEST_FUNCTIONS = ["test_10setAttributes"]
LIST_XARGS = ["lorem", "ipsum"]
PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def test_10setAttributes(self):
global mymsg
global jobObject
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
tcname = "TC0001"
tcproject = "TESTPROJ"
testcase = model.testcase.Testcase(job, tcproject)
# eigene Attribute vollstaendig
testcase = model.testcase.Testcase(job, tcproject)
args = {}
args[tcname] = {}
for k in model.testcase.LIST_FIELDS:
args[tcname][k] = "ATTR_" + k
testcase = testcase.setAttributes(job, args, tcname,
model.testcase.LIST_FIELDS,
model.testcase.LIST_NODES,
model.testcase.LIST_SUBTABLES)
for k in model.testcase.LIST_FIELDS:
if k == model.testcase.FIELD_NAME:
self.assertEqual(tcname, getattr(testcase, k))
elif k == model.testcase.FIELD_PROJECT:
self.assertEqual(tcproject, getattr(testcase, k))
else:
self.assertEqual(getattr(testcase, k), "ATTR_" + k)
for k in LIST_XARGS:
self.assertEqual(hasattr(testcase, k), False)
self.assertEqual(hasattr(testcase, tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS)), False)
# andere Attribute vollstaendig
testcase = model.testcase.Testcase(job, tcproject)
args = {}
args[tcname] = {}
attr = {}
for k in LIST_XARGS:
args[tcname][k] = "ATTR_" + k
attr[k] = "ATTR_" + k
args[tcname][B.NODE_ATTRIBUTES] = attr
topics = {}
for k in B.LIST_TOPIC_NODES:
topics[k] = {}
topics[k]["type"] = "x-type"
args[tcname][tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS)] = topics
testcase = testcase.setAttributes(job, args, tcname,
model.testcase.LIST_FIELDS,
model.testcase.LIST_NODES,
model.testcase.LIST_SUBTABLES)
for k in model.testcase.LIST_FIELDS:
if k == model.testcase.FIELD_NAME:
self.assertEqual(tcname, getattr(testcase, k))
elif k == model.testcase.FIELD_PROJECT:
self.assertEqual(tcproject, getattr(testcase, k))
else:
self.assertEqual("", getattr(testcase, k))
for k in LIST_XARGS:
self.assertEqual(hasattr(testcase, k), False)
for k in model.testcase.LIST_NODES:
self.assertEqual(hasattr(testcase, k), True)
self.assertEqual(hasattr(testcase, tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS)), True)
for k in B.LIST_TOPIC_NODES:
self.assertEqual(hasattr(testcase, k), False)
self.assertIn(k ,testcase.topics)
def test_11getEntities(self):
global mymsg
global jobObject
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
testcase = model.testcase.Testcase(job, "TESTPROJ")
entityNames = []
entityNames = testcase.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
#entityNames = testcase.get_entities(job, storage=model.entity.STORAGE_DB)
#self.assertEqual(type(entityNames), list)
def test_12getEntity(self):
global mymsg
global jobObject
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
testcase = model.testcase.Testcase(job, "TESTPROJ")
name = "TC0001"
acttestcase = testcase.read_entity(job, name)
self.assertEqual(getattr(acttestcase, model.testcase.FIELD_NAME), name)
self.assertRaises(Exception, testcase.read_entity, job, "xyzxyz")
if __name__ == '__main__':
unittest.main()

1
tools/data_const.py

@ -19,6 +19,7 @@ TYPE_PK = "pk"
TYPE_AUTOINT = "autoint" TYPE_AUTOINT = "autoint"
FIELD_NAME = "name" FIELD_NAME = "name"
FIELD_PROJECT = "project"
# fields in DDL # fields in DDL
# _field;comment;format;acceptance;generate;nullable # _field;comment;format;acceptance;generate;nullable

19
tools/data_tool.py

@ -33,6 +33,25 @@ def getPluralAttribut(inkey):
def getSingularAttribut(inkey): def getSingularAttribut(inkey):
return "_"+getPurKeyword(inkey) return "_"+getPurKeyword(inkey)
def getExistKeyword(inkey, inDict):
"""
returns the existing keyword in the dictionary
:param inkey: keyword in any form (singular/plural, as attribute or not)
:param inDict: the existing dictionary
:return:
"""
if inkey in inDict:
return inkey
if getSingularKeyword(inkey) in inDict:
return getSingularKeyword(inkey)
if getPluralKeyword(inkey) in inDict:
return getPluralKeyword(inkey)
if getSingularAttribut(inkey) in inDict:
return getSingularAttribut(inkey)
if getPluralAttribut(inkey) in inDict:
return getPluralAttribut(inkey)
return ""
def isStrDict(invalue): def isStrDict(invalue):
if isinstance(invalue, dict): if isinstance(invalue, dict):
return True return True

2
tools/filecsv_fcts.py

@ -101,7 +101,7 @@ class FileFcts(tools.file_abstract.FileFcts):
g) data-table: array: field - values # spec.data, comp.artifacts g) data-table: array: field - values # spec.data, comp.artifacts
:return: :return:
""" """
verify = True verify = False
tdata = {} tdata = {}
status = "start" status = "start"
verbose = False verbose = False

Loading…
Cancel
Save