Browse Source

some further classes, read-methods

refactor
Ulrich 1 year ago
parent
commit
06280e6290
  1. 2
      basic/connection.py
  2. 12
      basic/constants.py
  3. 6
      basic/testexecution.py
  4. 3
      model/application.csv
  5. 65
      model/application.py
  6. 74
      model/component.py
  7. 42
      model/entity.py
  8. 12
      model/project.csv
  9. 238
      model/project.py
  10. 57
      model/release.py
  11. 1
      model/step.csv
  12. 66
      model/step.py
  13. 2
      model/user.py
  14. 129
      test/test_16project.py
  15. 129
      test/test_17release.py
  16. 40
      test/test_20application.py
  17. 128
      test/test_22component.py
  18. 57
      test/test_28step.py
  19. 6
      tools/config_tool.py
  20. 6
      tools/data_const.py
  21. 3
      tools/filecsv_fcts.py
  22. 4
      tools/path_const.py

2
basic/connection.py

@ -39,7 +39,7 @@ class Connection(model.entity.Entity):
sql += dbi.getSchemaAttribut("port", D.TYPE_INT)+"," sql += dbi.getSchemaAttribut("port", D.TYPE_INT)+","
sql += dbi.getSchemaAttribut("hostname", D.TYPE_STR)+"," sql += dbi.getSchemaAttribut("hostname", D.TYPE_STR)+","
sql += dbi.getSchemaAttribut("dompath", D.TYPE_STR)+"," sql += dbi.getSchemaAttribut("dompath", D.TYPE_STR)+","
sql += dbi.getSchemaAttribut("attributes", D.TYPE_TEXT)+"," sql += dbi.getSchemaAttribut(B.NODE_ATTRIBUTES, D.TYPE_TEXT)+","
sql += self.getHistoryFields() sql += self.getHistoryFields()
sql += ");\n" sql += ");\n"
sql += dbi.getSchemaIndex("connection", "environment") + "\n" sql += dbi.getSchemaIndex("connection", "environment") + "\n"

12
basic/constants.py

@ -224,11 +224,18 @@ SUBJECT_INST = "instance" # | | | | x | CompHanldin
ATTR_INST_CNT = "count" # | | | | x | CompHanlding ATTR_INST_CNT = "count" # | | | | x | CompHanlding
ATTR_INST_SGL = "single" ATTR_INST_SGL = "single"
LIST_INST_ATTR = [ATTR_INST_CNT, ATTR_INST_SGL] LIST_INST_ATTR = [ATTR_INST_CNT, ATTR_INST_SGL]
SUBJECT_COMPS = "components" SUBJECT_COMP = "component"
SUBJECT_COMPS = SUBJECT_COMP+"s"
ATTR_INST_SUBCOMP = SUBJECT_COMPS ATTR_INST_SUBCOMP = SUBJECT_COMPS
ATTR_INST_TESTSERVER = "Testserver" ATTR_INST_TESTSERVER = "Testserver"
#SUBJECT_FCT = "function" # | | | | x | main-programs #SUBJECT_FCT = "function" # | | | | x | main-programs
SUBJECT_USECASE = "usecase"
SUBJECT_USECASES = SUBJECT_USECASE+"s"
SUBJECT_REL = "release"
SUBJECT_RELS = SUBJECT_REL+"s"
""" """
in this subject-node are each kind of result of any component with the structure: in this subject-node are each kind of result of any component with the structure:
* topic (db, cli, api, ...) * topic (db, cli, api, ...)
@ -244,7 +251,8 @@ ATTR_ARTS_LOG = "log"
ATTR_ARTS_LOB = "lob" ATTR_ARTS_LOB = "lob"
ATTR_ARTS_FILE = "file" ATTR_ARTS_FILE = "file"
#SUBJECT_DB = "databases" # | | | | # | db*_tools, match_tool #SUBJECT_DB = "databases" # | | | | # | db*_tools, match_tool
SUBJECT_PROJECTS = "projects" SUBJECT_PROJECT = "project"
SUBJECT_PROJECTS = SUBJECT_PROJECT+"s"
SUBJECT_ENV = PAR_ENV SUBJECT_ENV = PAR_ENV
SUBJECT_CONN = "conn" # | | x | | | conn_tool, db*_tools, cli*_toold SUBJECT_CONN = "conn" # | | x | | | conn_tool, db*_tools, cli*_toold

6
basic/testexecution.py

@ -30,14 +30,14 @@ class Testexecution(model.entity.Entity):
sql = dbi.getCreateTable("testexecution") sql = dbi.getCreateTable("testexecution")
sql += dbi.getSchemaAttribut("teid", "id")+"," sql += dbi.getSchemaAttribut("teid", "id")+","
sql += dbi.getSchemaAttribut("name", D.TYPE_STR)+"," sql += dbi.getSchemaAttribut("name", D.TYPE_STR)+","
sql += dbi.getSchemaAttribut("description", D.TYPE_TEXT)+"," sql += dbi.getSchemaAttribut(B.SUBJECT_REFERENCE, D.TYPE_TEXT)+","
sql += dbi.getSchemaAttribut("prelease", D.TYPE_STR)+"," sql += dbi.getSchemaAttribut("prelease", D.TYPE_STR)+","
sql += dbi.getSchemaAttribut("type", D.TYPE_STR)+"," sql += dbi.getSchemaAttribut("type", D.TYPE_STR)+","
sql += dbi.getSchemaAttribut("entity", D.TYPE_STR)+"," sql += dbi.getSchemaAttribut("entity", D.TYPE_STR)+","
sql += dbi.getSchemaAttribut("path", D.TYPE_STRING)+"," sql += dbi.getSchemaAttribut("path", D.TYPE_STRING)+","
sql += dbi.getSchemaAttribut("starttime", D.TYPE_TIME)+"," sql += dbi.getSchemaAttribut("starttime", D.TYPE_TIME)+","
sql += dbi.getSchemaAttribut("finishtime", D.TYPE_TIME)+"," sql += dbi.getSchemaAttribut("finishtime", D.TYPE_TIME)+","
sql += dbi.getSchemaAttribut("attributes", D.TYPE_TEXT)+"," sql += dbi.getSchemaAttribut(B.NODE_ATTRIBUTES, D.TYPE_TEXT)+","
sql += self.getHistoryFields() sql += self.getHistoryFields()
sql += ");\n" sql += ");\n"
sql += dbi.getSchemaIndex("testexecution", "release") + "\n" sql += dbi.getSchemaIndex("testexecution", "release") + "\n"
@ -46,7 +46,7 @@ class Testexecution(model.entity.Entity):
sql += dbi.getSchemaSubtable("te", [{"attr":attr, "atype": D.TYPE_STR}, sql += dbi.getSchemaSubtable("te", [{"attr":attr, "atype": D.TYPE_STR},
{"attr":"type", "atype": D.TYPE_STR}, {"attr":"type", "atype": D.TYPE_STR},
{"attr":"path", "atype": D.TYPE_STRING}, {"attr":"path", "atype": D.TYPE_STRING},
{"attr":"attributes", "atype": D.TYPE_TEXT}])+"\n" {"attr":B.NODE_ATTRIBUTES, "atype": D.TYPE_TEXT}])+"\n"
sql += dbi.getSchemaIndex(dbi.getSubTableName("te", attr), sql += dbi.getSchemaIndex(dbi.getSubTableName("te", attr),
dbi.getSubTableId(dbi.getSubTableName("te", attr), attr))+"\n" dbi.getSubTableId(dbi.getSubTableName("te", attr), attr))+"\n"
return sql return sql

3
model/application.csv

@ -1,8 +1,9 @@
table:application;_field;type;format;index;generic;aggregat;key;acceptance;alias;description table:application;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;apid;pk;int;N;;;;;; ;apid;pk;autoint;N;;;;;;
;name;str;vchar(256);I;;;;;; ;name;str;vchar(256);I;;;;;;
;description;string;vchar(256);N;;;;;; ;description;string;vchar(256);N;;;;;;
;reference;str;vchar(256);N;;;;;; ;reference;str;vchar(256);N;;;;;;
;project;str;vchar(256);N;;;;;;
;attributes;string;jlob;N;;;;;; ;attributes;string;jlob;N;;;;;;
;insauthor;str;vchar(256);N;;;;;; ;insauthor;str;vchar(256);N;;;;;;
;inscommit;str;vchar(256);N;;;;;; ;inscommit;str;vchar(256);N;;;;;;

1 table:application _field type format index generic aggregat key acceptance alias description
2 apid pk int autoint N
3 name str vchar(256) I
4 description string vchar(256) N
5 reference str vchar(256) N
6 project str vchar(256) N
7 attributes string jlob N
8 insauthor str vchar(256) N
9 inscommit str vchar(256) N

65
model/application.py

@ -6,14 +6,39 @@ import os
import basic.toolHandling import basic.toolHandling
import basic.constants as B import basic.constants as B
import model.entity import model.entity
import tools.data_const as D
import tools.path_const as P import tools.path_const as P
import tools.config_tool import tools.config_tool
import tools.file_tool import tools.file_tool
import tools.git_tool import tools.git_tool
TABLE_NAMES = ["application", "ap_project", "ap_component"] TABLE_NAMES = ["application", "ap_project", "ap_component"]
STORAGES = [model.entity.STORAGE_FILE, model.entity.STORAGE_DB]
""" used storage in priority sortage, so: if file then read_fcts / if db then select-fcts """
DEFAULT_SYNC = model.entity.SYNC_FULL_GIT2DB DEFAULT_SYNC = model.entity.SYNC_FULL_GIT2DB
TABLE_NAME = B.SUBJECT_APP
""" system-name for this entity """
FIELD_ID = "apid"
FIELD_NAME = D.FIELD_NAME
FIELD_DISCRIPTION = B.SUBJECT_REFERENCE
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DISCRIPTION, FIELD_REFERENCE, FIELD_PROJECT]
""" list of object-attributes """
SUB_COMPS = B.SUBJECT_COMPS
SUB_APPS = B.SUBJECT_APPS
SUB_RELS = B.SUBJECT_RELS
SUB_USECASE = B.SUBJECT_USECASES
LIST_SUBTABLES = [SUB_APPS, SUB_COMPS, SUB_RELS, SUB_USECASE]
FILE_EXTENSION = D.DFILE_TYPE_YML
UNIQUE_FIELDS = [FIELD_NAME]
""" unique business field as human identifer """
IDENTIFYER_FIELDS = [FIELD_ID]
""" unique technical field as technical identifer """
def getProjects(job): def getProjects(job):
""" """
get all project which are configured for the workspace get all project which are configured for the workspace
@ -194,13 +219,45 @@ def insertEntities(job,applData, dbTime, dbi):
# get list of application # get list of application
if dbTime != model.entity.VAL_ZERO_TIME: if dbTime != model.entity.VAL_ZERO_TIME:
for t in TABLE_NAMES: for t in TABLE_NAMES:
dbi.deleteRows(t, job) dbi.deleteRows(job, t)
for app in applData[B.SUBJECT_APPS]: for app in applData[B.SUBJECT_APPS]:
ao = Application(job) ao = Application(job)
ao.read_entity(job, app) ao.read_entity(job, app)
ao.insertEntity(dbi) ao.insertEntity(dbi)
class Application(model.entity.Entity): class Application(model.entity.Entity):
table = "application"
name = ""
description = ""
reference = ""
components = {}
project = {}
def read_unique_names(self, job, project, application, gran, args):
"""
reads the entity-names from file-storage
:param job:
:param opt. project: select-criteria if used and defined
:param opt. application: select-criteria if used and defined
:param opt. gran: granularity values testcase / testsuite / testplan
:param opt. args additional args
:return: list of entity-names
"""
config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS, tools.config_tool.get_plain_filename(job, ""))
outList = list(config[B.SUBJECT_APPS].keys())
return outList
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_APPS, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES)
class Application_old(model.entity.Entity):
table = "application" table = "application"
name = "" name = ""
description = "" description = ""
@ -325,11 +382,11 @@ class Application(model.entity.Entity):
def insertEntity(self, dbi=None): def insertEntity(self, dbi=None):
job = self.job job = self.job
rows = self.getApplicationRows(job) rows = self.getApplicationRows(job)
apid = dbi.insertRows(TABLE_NAMES[0], rows, job) apid = dbi.insertRows(job, TABLE_NAMES[0], rows)
rows = self.getAppProjectRows(job, apid) rows = self.getAppProjectRows(job, apid)
dbi.insertRows(TABLE_NAMES[1], rows, job) dbi.insertRows(job, TABLE_NAMES[1], rows)
rows = self.getAppComponentRows(job, apid) rows = self.getAppComponentRows(job, apid)
dbi.insertRows(TABLE_NAMES[2], rows, job) dbi.insertRows(job, TABLE_NAMES[2], rows)
def writeEntity(self): def writeEntity(self):
pass pass

74
model/component.py

@ -6,7 +6,9 @@ import os
import basic.toolHandling import basic.toolHandling
import basic.constants as B import basic.constants as B
import model.entity import model.entity
import model.application
# from model.Entity import Entity # from model.Entity import Entity
import tools.data_const as D
import tools.path_const as P import tools.path_const as P
import tools.config_tool as config_tool import tools.config_tool as config_tool
import tools.file_tool as file_tool import tools.file_tool as file_tool
@ -15,6 +17,18 @@ import tools.git_tool
TABLE_NAMES = ["component", "co_step", "co_table", "co_artifact", "co_comps"] TABLE_NAMES = ["component", "co_step", "co_table", "co_artifact", "co_comps"]
DEFAULT_SYNC = model.entity.SYNC_FULL_GIT2DB DEFAULT_SYNC = model.entity.SYNC_FULL_GIT2DB
TABLE_NAME = "component"
""" system-name for this entity """
FIELD_ID = "coid"
FIELD_NAME = D.FIELD_NAME
FIELD_DISCRIPTION = 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_DISCRIPTION, FIELD_REFERENCE]
""" list of object-attributes """
CP_SUBJECT_COMPS = "components" CP_SUBJECT_COMPS = "components"
CP_SUBJECT_STEPS = "steps" CP_SUBJECT_STEPS = "steps"
CP_SUBJECT_TABLES = "tables" CP_SUBJECT_TABLES = "tables"
@ -32,7 +46,6 @@ LIST_REL_ATTR = [REL_ATTR_TYPE, REL_ATTR_FILE, REL_ATTR_FTYPE,
REL_ATTR_IP_PATTERN, REL_ATTR_HOST_PATTERN, REL_ATTR_PORT_PATTERN, REL_ATTR_URL_PATTERN] REL_ATTR_IP_PATTERN, REL_ATTR_HOST_PATTERN, REL_ATTR_PORT_PATTERN, REL_ATTR_URL_PATTERN]
def select_components(job, project, application): def select_components(job, project, application):
""" """
get all project which are configured for the workspace get all project which are configured for the workspace
@ -54,16 +67,65 @@ def select_components(job, project, application):
return outList return outList
class Component(model.entity.Entity): class Component(model.entity.Entity):
def __init__(self, job, name=""): coid = 0
name = ""
description = ""
reference = ""
project = ""
application = ""
attributes = ""
def __init__(self, job="", name=""):
pass pass
def read_unique_names(self, job, project, application, gran, args):
"""
reads the entity-names from file-storage
:param job:
:param opt. project: select-criteria if used and defined
:param opt. application: select-criteria if used and defined
:param opt. gran: granularity values testcase / testsuite / testplan
:param opt. args additional args
:return: list of entity-names
"""
outList = []
# suche weiterleiten
if application != "":
app = model.application.Application()
return list(app.components.keys())
path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS])
for k in os.listdir(path):
if k[:1] in [".", "_"]:
continue
if k in [P.KEY_CATALOG, P.KEY_TOOL, P.VAL_CONFIG, P.VAL_TEST, P.VAL_TOOLS]:
continue
if not os.path.isdir(os.path.join(path, k)):
continue
outList.append(k)
return outList
def read_entity(self, job, name): def read_entity(self, job, name):
"""
reads the entity from the file-system
:param job:
:param name:
:return:
"""
configPath = tools.config_tool.select_config_path(job, P.KEY_COMP, name, "") configPath = tools.config_tool.select_config_path(job, P.KEY_COMP, name, "")
repoPath = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], name) #repoPath = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], name)
gitresult = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, repoPath, 1) #gitresult = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, repoPath, 1)
configTree = file_tool.read_file_dict(job, configPath, job.m) config = file_tool.read_file_dict(job, configPath, job.m)
print("ok") print("ok")
return for k in LIST_FIELDS:
if k not in config[TABLE_NAME]:
continue
setattr(self, k, config[TABLE_NAME][k])
for k in LIST_CP_SUBJECTS:
if k not in config[TABLE_NAME]:
continue
setattr(self, k, config[TABLE_NAME][k])
return self
def write_entity(self, job, name): def write_entity(self, job, name):
return return

42
model/entity.py

@ -5,11 +5,12 @@ import basic.toolHandling
import model.entity import model.entity
import tools.data_const as D import tools.data_const as D
import basic.constants as B import basic.constants as B
import tools.config_tool
import tools.date_tool import tools.date_tool
import tools.file_tool import tools.file_tool
ENTITY_NAME = "name" ENTITY_NAME = "name"
ENTITY_ATTRIBUTES = "attributes" ENTITY_ATTRIBUTES = B.NODE_ATTRIBUTES
ENTITY_INS_COMMIT = "inscommit" ENTITY_INS_COMMIT = "inscommit"
ENTITY_INS_AUTHOR = "insauthor" ENTITY_INS_AUTHOR = "insauthor"
ENTITY_INS_TIME = "instime" ENTITY_INS_TIME = "instime"
@ -235,6 +236,45 @@ class Entity:
""" """
raise Exception(B.EXCEPT_NOT_IMPLEMENT) raise Exception(B.EXCEPT_NOT_IMPLEMENT)
""" 2023-05 """
@staticmethod
def getConfig(job, module, subject, name):
"""
reads the entity from the database
it should get the same result like read_entity
:param job:
:param name:
:return:
"""
config = tools.config_tool.getConfig(job, module, subject)
if config is not None:
if len(name) == 0:
return config
elif name in config[subject]:
outConfig = {}
outConfig[name] = config[subject][name]
return outConfig
elif B.DATA_NODE_KEYS in config[subject] \
and name in config[subject][B.DATA_NODE_KEYS]:
# if csv-data is a catalog
outConfig = {}
outConfig[name] = config[subject][B.DATA_NODE_KEYS][name]
return outConfig
raise Exception("keine Config zu "+name)
def setAttributes(self, config, rootname, fields, subjects):
""" 2023-05 """
for k in fields:
if k not in config[rootname]:
continue
setattr(self, k, config[rootname][k])
for k in subjects:
if k not in config[rootname]:
continue
setattr(self, k, config[rootname][k])
return self
def getDbAttr(self, job): def getDbAttr(self, job):
out = {} out = {}
for attr in [B.ATTR_DB_HOST, B.ATTR_DB_USER, B.ATTR_DB_DATABASE, B.ATTR_DB_PASSWD]: for attr in [B.ATTR_DB_HOST, B.ATTR_DB_USER, B.ATTR_DB_DATABASE, B.ATTR_DB_PASSWD]:

12
model/project.csv

@ -0,0 +1,12 @@
table:project;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;prid;pk;int;N;;;;;;
;name;str;vchar(256);I;;;;;;
;description;string;vchar(256);N;;;;;;
;reference;str;vchar(256);N;;;;;;
;insauthor;str;vchar(256);N;;;;;;
;inscommit;str;vchar(256);N;;;;;;
;instime;time;vchar(256);N;;;;;;
;updauthor;str;vchar(256);N;;;;;;
;updcommit;str;vchar(256);N;;;;;;
;updtime;time;vchar(256);N;;;;;;
;actual;int;vchar(256);I;;;;;;
1 table:project _field type format index generic aggregat key acceptance alias description
2 prid pk int N
3 name str vchar(256) I
4 description string vchar(256) N
5 reference str vchar(256) N
6 insauthor str vchar(256) N
7 inscommit str vchar(256) N
8 instime time vchar(256) N
9 updauthor str vchar(256) N
10 updcommit str vchar(256) N
11 updtime time vchar(256) N
12 actual int vchar(256) I

238
model/project.py

@ -0,0 +1,238 @@
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import os
import basic.toolHandling
import basic.constants as B
import model.entity
import tools.path_const as P
import tools.data_const as D
import tools.config_tool
import tools.file_tool
import tools.db_abstract
import tools.git_tool
TABLE_NAME = "project"
""" system-name for this entity """
FIELD_ID = "prid"
FIELD_NAME = "name"
FIELD_DISCRIPTION = B.SUBJECT_REFERENCE
FIELD_REFERENCE = B.SUBJECT_REFERENCE
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DISCRIPTION, FIELD_REFERENCE]
""" list of object-attributes """
FILE_EXTENSION = D.DFILE_TYPE_YML
UNIQUE_FIELDS = [FIELD_NAME]
""" unique business field as human identifer """
IDENTIFYER_FIELDS = [FIELD_ID]
""" unique technical field as technical identifer """
class Project(model.entity.Entity):
prid = 0
name = ""
description = ""
reference = ""
def __int__(self, job, name=""):
self.job = job
if len(name) > 1:
self.getEntity(job, name)
def read_unique_names(self, job, project, application, gran, args):
"""
reads the entity-names from file-storage
:param job:
:param opt. project: select-criteria if used and defined
:param opt. application: select-criteria if used and defined
:param opt. gran: granularity values testcase / testsuite / testplan
:param opt. args additional args
:return: list of entity-names
"""
config = self.getConfig(job, B.SUBJECT_PROJECTS, "")
outList = list(config[B.SUBJECT_PROJECTS].keys())
return outList
def select_unique_names(self, job, project, application, gran, args):
"""
reads the entity-names from file-storage
:param job:
:param opt. project: select-criteria if used and defined
:param opt. application: select-criteria if used and defined
:param opt. gran: granularity values testcase / testsuite / testplan
:param opt. args additional args
:return: list of entity-names
"""
outList = []
self.setDbAttributes(job, [TABLE_NAME])
dbi = basic.toolHandling.getDbTool(job, self, job.conf[B.TOPIC_NODE_DB]["type"])
data = dbi.selectRows(TABLE_NAME, job)
checkList = {}
for row in data[B.DATA_NODE_DATA]:
key = ""
for f in UNIQUE_FIELDS:
key += "_" + row[f]
if key in checkList:
continue
else:
checkList[key] = key
fields = []
for f in UNIQUE_FIELDS:
fields.append(row[f])
outList.append(fields)
return outList
def read_entity(self, job, name):
"""
reads the entity from the file-system
:param job:
:param name:
:return:
"""
print("name "+name)
config = self.getConfig(job, B.SUBJECT_PROJECTS, tools.config_tool.get_plain_filename(job, name))
for k in LIST_FIELDS:
if k not in config:
continue
setattr(self, k, config[k])
return self
def select_entity(self, job, name, row={}):
"""
reads the entity from the database
it should get the same result like read_entity
:param job:
:param name: unique field as string, unique fields as list
the unique-fields are defined in the class
:return: itself with filled object-attributes
"""
if row is None or len(row) == 0:
self.setDbAttributes(job, [TABLE_NAME])
dbi = basic.toolHandling.getDbTool(job, self, job.conf[B.TOPIC_NODE_DB]["type"])
if type(name) is list:
names = name
elif type(name) is str:
names = [name]
condition = "where "
for v in names:
condition += " and " + ""
data = dbi.selectRows(TABLE_NAME, job, "where username = \'" + names[0] + "\'")
if len(data[B.DATA_NODE_DATA]) > 1:
raise Exception("single selection with more than one result: "+names[0])
elif len(data[B.DATA_NODE_DATA]) == 1:
row = data[B.DATA_NODE_DATA][0]
else:
raise Exception("no result for: "+names[0])
for k in LIST_FIELDS:
if k not in row:
continue
setattr(self, k, row[k])
return self
def write_entity(self, job, name):
"""
writes the entity into the file-system
it similar to update_entity
:param job:
:param name:
:return:
"""
config = {}
config[model.user.TABLE_NAME] = {}
pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG,
P.VAL_USER, name + ".yml")
for k in LIST_FIELDS:
if getattr(self, k, "") == "" \
or k == FIELD_ID:
continue
config[model.user.TABLE_NAME][k] = getattr(self, k, "")
tools.file_tool.write_file_dict(job.m, job, pathname, config)
return self
def insert_entity(self, job, name, table="", rows={}):
"""
inserts the entity into the database
it similar to update_entity
:param job:
:param name:
:return:
"""
self.setDbAttributes(job, [TABLE_NAME])
dbi = basic.toolHandling.getDbTool(job, self, job.conf[B.TOPIC_NODE_DB]["type"])
condition = "where"
for f in UNIQUE_FIELDS:
# TODO other db-formats than string has to be implemented
condition += " and " + f + " = \'" + getattr(self, f, "") + "\'"
condition = condition.replace("where and", "where ")
data = dbi.selectRows(TABLE_NAME, job, condition)
if len(data[B.DATA_NODE_DATA]) > 0:
print("update statt insert")
return
if rows is None or len(rows) == 0:
insheader = dbi.getInsertFields(self.conf[B.DATA_NODE_DDL][table])
rows = []
row = {}
for f in insheader:
row[f] = getattr(self, f)
rows.append(row)
dbi.insertRows(job, table, rows)
def update_entity(self, job, name):
"""
writes the entity into the database
it similar to update_entity
:param job:
:param name:
:return:
"""
raise Exception(B.EXCEPT_NOT_IMPLEMENT)
def remove_entity(self, job, name):
"""
removes the entity from the file-system
it similar to delete_entity
:param job:
:param name: single substring or list of name or dict of names with the keys as
:return:
"""
self.removeEntity(job, name, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, P.VAL_USER), "yml")
def delete_entity(self, job, name, table):
"""
deletes the entity into the database
it similar to update_entity
:param job:
:param name:
:return:
"""
self.setDbAttributes(job, [TABLE_NAME])
dbi = basic.toolHandling.getDbTool(job, self, job.conf[B.TOPIC_NODE_DB]["type"])
condition = "where"
for f in IDENTIFYER_FIELDS:
# TODO other db-formats than string has to be implemented
val = dbi.getDbValue(self.conf[B.DATA_NODE_DDL][table][f], getattr(self, f, ""))
condition += " and " + f + " = " + val + ""
condition = condition.replace("where and", "where ")
dbi.deleteRows(job, table, condition)
@staticmethod
def getConfig(job, subject, name):
"""
reads the entity from the database
it should get the same result like read_entity
:param job:
:param name:
:return:
"""
config = tools.config_tool.getConfig(job, P.KEY_BASIC, subject)
if config is not None:
if len(name) == 0:
return config
elif name in config[subject]:
return config[subject][name]
raise Exception("keine Config zu "+name)
@staticmethod
def getCurrentUser(job):
return os.environ.get("USERNAME")

57
model/release.py

@ -2,19 +2,72 @@
# Author : Ulrich Carmesin # Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de # Source : gitea.ucarmesin.de
# --------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------
import basic.toolHandling
import basic.componentHandling
import basic.constants as B import basic.constants as B
import model.entity import model.entity
import tools.path_const as P
import tools.data_const as D
import tools.config_tool
import tools.file_tool
import tools.git_tool
TABLE_NAME = "step"
""" system-name for this entity """
FIELD_ID = "rlid"
FIELD_NAME = "name"
FIELD_DISCRIPTION = B.SUBJECT_REFERENCE
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_APPLICATION = B.SUBJECT_APP
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DISCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_APPLICATION, FIELD_ATTRIBUTES]
""" list of object-attributes """
LIST_SUBTABLES = []
FILE_EXTENSION = D.DFILE_TYPE_CSV
UNIQUE_FIELDS = [FIELD_NAME]
""" unique business field as human identifer """
IDENTIFYER_FIELDS = [FIELD_ID]
""" unique technical field as technical identifer """
class Release(model.entity.Entity): class Release(model.entity.Entity):
rlid = 0 rlid = 0
release = "" name = ""
project = "" project = ""
application = ""
description = "" description = ""
reference = "" reference = ""
def __init__(self, job, project="", name=""): def __init__(self, job, project, name=""):
""" """
to be initialized by readSpec to be initialized by readSpec
:param job: :param job:
""" """
self.job = job self.job = job
self.project = project
def read_unique_names(self, job, project, application, gran, args):
"""
reads the entity-names from file-storage
:param job:
:param opt. project: select-criteria if used and defined
:param opt. application: select-criteria if used and defined
:param opt. gran: granularity values testcase / testsuite / testplan
:param opt. args additional args
:return: list of entity-names
"""
config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_RELS, tools.config_tool.get_plain_filename(job, ""))
outList = list(config[B.SUBJECT_RELS][B.DATA_NODE_KEYS].keys())
return outList
def read_entity(self, job, name):
"""
reads the entity from the file-system
:param job:
:param name:
:return:
"""
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)

1
model/step.csv

@ -3,6 +3,7 @@ table:step;_field;type;format;index;generic;aggregat;key;acceptance;alias;descri
;name;str;vchar(256);I;;;;;; ;name;str;vchar(256);I;;;;;;
;description;string;vchar(256);N;;;;;; ;description;string;vchar(256);N;;;;;;
;reference;str;vchar(256);N;;;;;; ;reference;str;vchar(256);N;;;;;;
;component;str;vchar(256);N;;;;;;
;attributes;string;jlob;N;;;;;; ;attributes;string;jlob;N;;;;;;
;insauthor;str;vchar(256);N;;;;;; ;insauthor;str;vchar(256);N;;;;;;
;inscommit;str;vchar(256);N;;;;;; ;inscommit;str;vchar(256);N;;;;;;

1 table:step _field type format index generic aggregat key acceptance alias description
3 name str vchar(256) I
4 description string vchar(256) N
5 reference str vchar(256) N
6 component str vchar(256) N
7 attributes string jlob N
8 insauthor str vchar(256) N
9 inscommit str vchar(256) N

66
model/step.py

@ -4,13 +4,33 @@
# --------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------
import os import os
import basic.toolHandling import basic.toolHandling
import basic.componentHandling
import basic.constants as B import basic.constants as B
import model.entity import model.entity
import tools.path_const as P import tools.path_const as P
import tools.data_const as D
import tools.config_tool import tools.config_tool
import tools.file_tool import tools.file_tool
import tools.git_tool import tools.git_tool
TABLE_NAME = "step"
""" system-name for this entity """
FIELD_ID = "spid"
FIELD_NAME = "name"
FIELD_DISCRIPTION = B.SUBJECT_REFERENCE
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_COMPONENT = B.SUBJECT_COMP
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DISCRIPTION, FIELD_REFERENCE, FIELD_COMPONENT]
""" list of object-attributes """
LIST_SUBTABLES = []
FILE_EXTENSION = D.DFILE_TYPE_YML
UNIQUE_FIELDS = [FIELD_NAME]
""" unique business field as human identifer """
IDENTIFYER_FIELDS = [FIELD_ID]
""" unique technical field as technical identifer """
STEP_ATTR_NR = "nr" STEP_ATTR_NR = "nr"
""" unique number in test-specification / in comp the array-position """ """ unique number in test-specification / in comp the array-position """
STEP_ATTR_GROUP = "step" STEP_ATTR_GROUP = "step"
@ -47,7 +67,7 @@ class Step(model.entity.Entity):
description = "" description = ""
project = "" project = ""
group = 0 group = 0
comp = "" component = ""
fct = "" fct = ""
tool = "" tool = ""
toolname = "" toolname = ""
@ -56,6 +76,10 @@ class Step(model.entity.Entity):
def __init__(self, job, project="", name="", obj=None): def __init__(self, job, project="", name="", obj=None):
""" """
to be initialized by readSpec 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: :param job:
""" """
self.job = job self.job = job
@ -64,12 +88,42 @@ class Step(model.entity.Entity):
if len(name) > 1: if len(name) > 1:
self.name = name self.name = name
if obj is not None: if obj is not None:
self.setEntity(LIST_STEP_ATTR, obj) self.setEntity(LIST_STEP_ATTR, name, obj)
else: else:
self.getEntity(job, name) self.getEntity(job, name)
def setEntity(self, keys, obj): def read_unique_names(self, job, project, application, gran, args):
for k in keys: """
if k in obj: reads the entity-names from file-storage
setattr(self, k, obj[k]) :param job:
:param opt. project: select-criteria if used and defined
:param opt. application: select-criteria if used and defined
:param opt. gran: granularity values testcase / testsuite / testplan
:param opt. args additional args
:return: list of entity-names
"""
config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, tools.config_tool.get_plain_filename(job, ""))
outList = list(config[B.SUBJECT_VARIANTS].keys())
return outList
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(config, name, LIST_FIELDS, LIST_SUBTABLES)
def rest_read(self, job, name):
print("step read "+name)
variants = tools.config_tool.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS)["variants"]
if name not in variants:
raise Exception("Argument Variant "+name+" nicht definiert.")
variant = variants[name]
if not "comp" in variant:
raise Exception("Keine Komponente zu "+name+" definiert.")
cm = basic.componentHandling.ComponentManager.getInstance(job)
comp = cm.getComponent(variant["comp"])
print(str(comp))

2
model/user.py

@ -21,7 +21,7 @@ FIELD_NAME = "name"
FIELD_FAMNAME = "famname" FIELD_FAMNAME = "famname"
FIELD_EMAIL = "email" FIELD_EMAIL = "email"
FIELD_PASSWORD = "password" FIELD_PASSWORD = "password"
FIELD_PROJECT = "project" 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 """

129
test/test_16project.py

@ -0,0 +1,129 @@
import unittest
import os
import inspect
import tools.path_tool
import basic.program
import test.testtools
import basic.constants as B
import test.constants as T
import model.project
import model.entity
HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10getEntityNames", "test_11getEntities", "test_12getEntity",
"test_13writeEntity", "test_14insertEntity"]
TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity"]
PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def test_10getEntityNames(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()
project = model.project.Project()
entityNames = []
entityNames = project.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
#entityNames = project.select_unique_names(job, "", "", "", {})
#self.assertEquals(type(entityNames), list)
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()
project = model.project.Project()
entityNames = []
entityNames = project.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
entityNames = project.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()
project = model.project.Project()
name = "TESTPROJ"
actproject = project.read_entity(job, name)
self.assertEqual(getattr(actproject, model.project.FIELD_NAME), name)
self.assertRaises(Exception, project.read_entity, job, "xyzxyz")
#
#actproject = project.select_entity(job, name)
#self.assertEqual(getattr(actproject, model.project.FIELD_USERNAME), name)
#self.assertRaises(Exception, project.select_entity, job, ["xyzxyz"])
def test_13writeEntity(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()
username = "hans_xyz"
project = model.project.Project()
entityNames = project.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
project.username = username
project.name = "Hans"
project.famname = "im Glueck"
project.project = "TESTPROJ"
project.write_entity(job, username)
entityNames = project.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertIn(username, entityNames)
actUser = project.read_entity(job, username)
self.assertEquals(getattr(actUser, model.project.FIELD_USERNAME), username)
actUser.remove_entity(job, username)
entityNames = project.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
def test_14insertEntity(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()
username = "hans_xyz"
project = model.project.Project()
entityNames = collectInnerList(project.get_unique_names(job, storage=model.entity.STORAGE_DB))
#self.assertNotIn(username, entityNames)
project.username = username
project.name = "Hans"
project.famname = "im Glueck"
project.project = "TESTPROJ"
#project.insert_entity(job, username, table="project")
entityNames = collectInnerList(project.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertIn(username, entityNames)
actUser = project.select_entity(job, username)
self.assertEquals(getattr(actUser, model.project.FIELD_USERNAME), username)
actUser.delete_entity(job, username, "project")
entityNames = collectInnerList(project.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertNotIn(username, entityNames)
def collectInnerList(inList):
outList = []
for r in inList:
outList += r
return outList
if __name__ == '__main__':
unittest.main()

129
test/test_17release.py

@ -0,0 +1,129 @@
import unittest
import os
import inspect
import tools.path_tool
import basic.program
import test.testtools
import basic.constants as B
import test.constants as T
import model.release
import model.entity
HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10getEntityNames", "test_11getEntities", "test_12getEntity",
"test_13writeEntity", "test_14insertEntity"]
TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity"]
PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def test_10getEntityNames(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()
release = model.release.Release(job, "TESTPROJ")
entityNames = []
entityNames = release.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
#entityNames = project.select_unique_names(job, "", "", "", {})
#self.assertEquals(type(entityNames), list)
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()
release = model.release.Release(job, "TESTPROJ")
entityNames = []
entityNames = release.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
#entityNames = release.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()
release = model.release.Release(job, "TESTPROJ")
name = "V-1.1.0"
actrelease = release.read_entity(job, name)
self.assertEqual(getattr(actrelease, model.project.FIELD_NAME), name)
self.assertRaises(Exception, release.read_entity, job, "xyzxyz")
#
#actproject = project.select_entity(job, name)
#self.assertEqual(getattr(actproject, model.project.FIELD_USERNAME), name)
#self.assertRaises(Exception, project.select_entity, job, ["xyzxyz"])
def test_13writeEntity(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()
username = "hans_xyz"
project = model.project.Project()
entityNames = project.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
project.username = username
project.name = "Hans"
project.famname = "im Glueck"
project.project = "TESTPROJ"
project.write_entity(job, username)
entityNames = project.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertIn(username, entityNames)
actUser = project.read_entity(job, username)
self.assertEquals(getattr(actUser, model.project.FIELD_USERNAME), username)
actUser.remove_entity(job, username)
entityNames = project.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
def test_14insertEntity(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()
username = "hans_xyz"
project = model.project.Project()
entityNames = collectInnerList(project.get_unique_names(job, storage=model.entity.STORAGE_DB))
#self.assertNotIn(username, entityNames)
project.username = username
project.name = "Hans"
project.famname = "im Glueck"
project.project = "TESTPROJ"
#project.insert_entity(job, username, table="project")
entityNames = collectInnerList(project.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertIn(username, entityNames)
actUser = project.select_entity(job, username)
self.assertEquals(getattr(actUser, model.project.FIELD_USERNAME), username)
actUser.delete_entity(job, username, "project")
entityNames = collectInnerList(project.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertNotIn(username, entityNames)
def collectInnerList(inList):
outList = []
for r in inList:
outList += r
return outList
if __name__ == '__main__':
unittest.main()

40
test/test_20application.py

@ -13,14 +13,50 @@ import model.application
HOME_PATH = test.constants.HOME_PATH HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python" PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10getApplications"] TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity", "test_10getApplications"]
TEST_FUNCTIONS = ["test_12getEntity"]
PROGRAM_NAME = "clean_workspace" PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------" mymsg = "--------------------------------------------------------------"
def test_10getApplications(self): def test_10getEntityNames(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()
application = model.application.Application()
entityNames = []
entityNames = application.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
print("apps "+str(entityNames))
#entityNames = component.select_unique_names(job, "", "", "", {})
#self.assertEquals(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()
application = model.application.Application()
name = "TESTAPP"
actproject = application.read_entity(job, name)
self.assertEqual(getattr(actproject, model.application.FIELD_NAME), name)
self.assertRaises(Exception, application.read_entity, job, "xyzxyz")
#
#actproject = component.select_entity(job, name)
#self.assertEqual(getattr(actproject, model.component.FIELD_USERNAME), name)
#self.assertRaises(Exception, component.select_entity, job, ["xyzxyz"])
def test_xx10getApplications(self):
global mymsg global mymsg
global jobObject global jobObject
actfunction = str(inspect.currentframe().f_code.co_name) actfunction = str(inspect.currentframe().f_code.co_name)

128
test/test_22component.py

@ -0,0 +1,128 @@
import unittest
import os
import inspect
import tools.path_tool
import basic.program
import test.testtools
import basic.constants as B
import test.constants as T
import model.component
import model.entity
HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10getEntityNames", "test_11getEntities", "test_12getEntity",
"test_13writeEntity", "test_14insertEntity"]
TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity"]
PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def test_10getEntityNames(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()
component = model.component.Component(job)
entityNames = []
entityNames = component.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
#entityNames = component.select_unique_names(job, "", "", "", {})
#self.assertEquals(type(entityNames), list)
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()
component = model.component.component()
entityNames = []
entityNames = component.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
entityNames = component.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()
component = model.component.Component(job)
name = "testprd"
actproject = component.read_entity(job, name)
self.assertEqual(getattr(actproject, model.component.FIELD_NAME), name)
self.assertRaises(Exception, component.read_entity, job, "xyzxyz")
#
#actproject = component.select_entity(job, name)
#self.assertEqual(getattr(actproject, model.component.FIELD_USERNAME), name)
#self.assertRaises(Exception, component.select_entity, job, ["xyzxyz"])
def test_13writeEntity(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()
username = "hans_xyz"
component = model.component.component()
entityNames = component.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
component.username = username
component.name = "Hans"
component.famname = "im Glueck"
component.component = "TESTPROJ"
component.write_entity(job, username)
entityNames = component.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertIn(username, entityNames)
actUser = component.read_entity(job, username)
self.assertEquals(getattr(actUser, model.component.FIELD_USERNAME), username)
actUser.remove_entity(job, username)
entityNames = component.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
def test_14insertEntity(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()
username = "hans_xyz"
component = model.component.component()
entityNames = collectInnerList(component.get_unique_names(job, storage=model.entity.STORAGE_DB))
#self.assertNotIn(username, entityNames)
component.username = username
component.name = "Hans"
component.famname = "im Glueck"
component.component = "TESTPROJ"
#component.insert_entity(job, username, table="component")
entityNames = collectInnerList(component.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertIn(username, entityNames)
actUser = component.select_entity(job, username)
self.assertEquals(getattr(actUser, model.component.FIELD_USERNAME), username)
actUser.delete_entity(job, username, "component")
entityNames = collectInnerList(component.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertNotIn(username, entityNames)
def collectInnerList(inList):
outList = []
for r in inList:
outList += r
return outList
if __name__ == '__main__':
unittest.main()

57
test/test_28step.py

@ -13,14 +13,51 @@ import model.step
HOME_PATH = test.constants.HOME_PATH HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python" PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10getEnvironments"] TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity", "test_20getStep"]
TEST_FUNCTIONS = ["test_12getEntity"]
PROGRAM_NAME = "clean_workspace" PROGRAM_NAME = "clean_workspace"
PROJECT = "TESTPROJ"
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------" mymsg = "--------------------------------------------------------------"
def test_10getEnvironments(self): def test_10getEntityNames(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()
step = model.step.Step(job)
entityNames = []
entityNames = step.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
print("apps "+str(entityNames))
#entityNames = component.select_unique_names(job, "", "", "", {})
#self.assertEquals(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()
step = model.step.Step(job)
name = "xml-rest"
actproject = step.read_entity(job, name)
self.assertEqual(getattr(actproject, model.step.FIELD_NAME), name)
self.assertRaises(Exception, step.read_entity, job, "xyzxyz")
#
#actproject = component.select_entity(job, name)
#self.assertEqual(getattr(actproject, model.component.FIELD_USERNAME), name)
#self.assertRaises(Exception, component.select_entity, job, ["xyzxyz"])
def test_10getSteps(self):
global mymsg global mymsg
global jobObject global jobObject
actfunction = str(inspect.currentframe().f_code.co_name) actfunction = str(inspect.currentframe().f_code.co_name)
@ -31,9 +68,21 @@ class MyTestCase(unittest.TestCase):
job = test.testtools.getJob() job = test.testtools.getJob()
print(str(job.__dict__)) print(str(job.__dict__))
jobObject = job jobObject = job
projList = ["TESTPROJ"]
appList = []
def test_20getStep(self):
global mymsg
global jobObject
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
# simple job instantiate - without parameter and only simple messaging
job = test.testtools.getJob()
print(str(job.__dict__))
jobObject = job
# step-name = variant
step = model.step.Step(job, PROJECT, name="json-rest")
print(str(step))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

6
tools/config_tool.py

@ -138,7 +138,7 @@ def getToolPath(job, name, subname):
if path is not None: if path is not None:
return path return path
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM],
P.VAL_UTIL, P.VAL_CONFIG, name)) P.VAL_TOOLS, P.VAL_CONFIG, name))
if path is not None: if path is not None:
return path return path
raise Exception(P.EXP_CONFIG_MISSING, envdir + ", " + name) raise Exception(P.EXP_CONFIG_MISSING, envdir + ", " + name)
@ -197,9 +197,9 @@ def getTestPath(job, name, filename):
return pathname return pathname
def getCatalogPath(job, name): def getCatalogPath(job, name):
if hasattr(job, "par") and hasattr(job.par, "project"): if hasattr(job, "par") and hasattr(job.par, B.SUBJECT_PROJECT):
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA],
getattr(job.par, "project"), P.KEY_CATALOG, name)) getattr(job.par, B.SUBJECT_PROJECT), P.KEY_CATALOG, name))
if path is not None: if path is not None:
return path return path

6
tools/data_const.py

@ -18,6 +18,8 @@ TYPE_TIME = "time"
TYPE_PK = "pk" TYPE_PK = "pk"
TYPE_AUTOINT = "autoint" TYPE_AUTOINT = "autoint"
FIELD_NAME = "name"
# fields in DDL # fields in DDL
# _field;comment;format;acceptance;generate;nullable # _field;comment;format;acceptance;generate;nullable
DDL_FIELD = "_field" DDL_FIELD = "_field"
@ -37,7 +39,7 @@ DDL_KEY = "key"
""" see acceptance_tool """ """ see acceptance_tool """
DDL_ACCEPTANCE = "acceptance" DDL_ACCEPTANCE = "acceptance"
DDL_ALIAS = "alias" DDL_ALIAS = "alias"
DDL_DESCRIPTION = "description" DDL_DESCRIPTION = B.SUBJECT_REFERENCE
LIST_DDL_ATTR = [DDL_FIELD, DDL_TYPE, DDL_FORMAT, DDL_INDEX, DDL_GENERIC, LIST_DDL_ATTR = [DDL_FIELD, DDL_TYPE, DDL_FORMAT, DDL_INDEX, DDL_GENERIC,
DDL_AGGREGAT, DDL_KEY, DDL_ACCEPTANCE, DDL_ALIAS, DDL_DESCRIPTION] DDL_AGGREGAT, DDL_KEY, DDL_ACCEPTANCE, DDL_ALIAS, DDL_DESCRIPTION]
@ -77,6 +79,7 @@ LIST_DATA_ATTR = [DATA_ATTR_TYPE, DATA_ATTR_COUNT, DATA_ATTR_DATE, DATA_ATTR_CHA
DATA_ATTR_REF, DATA_ATTR_IDS, DATA_ATTR_ALIAS, DATA_ATTR_KEY, DATA_ATTR_TBL, DATA_ATTR_DLIM] DATA_ATTR_REF, DATA_ATTR_IDS, DATA_ATTR_ALIAS, DATA_ATTR_KEY, DATA_ATTR_TBL, DATA_ATTR_DLIM]
LIST_ATTR_CONST = ["DATA_ATTR_COUNT", "DATA_ATTR_DATE", "DATA_ATTR_CHAR", "DATA_ATTR_COMP", "DATA_ATTR_ALIAS", "DATA_ATTR_KEY"] LIST_ATTR_CONST = ["DATA_ATTR_COUNT", "DATA_ATTR_DATE", "DATA_ATTR_CHAR", "DATA_ATTR_COMP", "DATA_ATTR_ALIAS", "DATA_ATTR_KEY"]
# attributes in testcase-specification
HEAD_ATTR_DESCR = "decription" HEAD_ATTR_DESCR = "decription"
HEAD_ATTR_TARGET = "target" HEAD_ATTR_TARGET = "target"
HEAD_ATTR_USECASE = "usecase" HEAD_ATTR_USECASE = "usecase"
@ -91,6 +94,7 @@ LIST_HEAD_ATTR = [HEAD_ATTR_DESCR, HEAD_ATTR_TARGET, HEAD_ATTR_USECASE, HEAD_ATT
LIST_HEAD_CONST = ["HEAD_ATTR_DESCR", "HEAD_ATTR_TARGET", "HEAD_ATTR_USECASE", "HEAD_ATTR_UCID", LIST_HEAD_CONST = ["HEAD_ATTR_DESCR", "HEAD_ATTR_TARGET", "HEAD_ATTR_USECASE", "HEAD_ATTR_UCID",
"HEAD_ATTR_STORY", "HEAD_ATTR_STORYID", "HEAD_ATTR_APPS", "HEAD_ATTR_DEPR"] "HEAD_ATTR_STORY", "HEAD_ATTR_STORYID", "HEAD_ATTR_APPS", "HEAD_ATTR_DEPR"]
# attributes in testcase-specification
OPT_ATTR_DESCR = "decription" OPT_ATTR_DESCR = "decription"
OPT_ATTR_TARGET = "target" OPT_ATTR_TARGET = "target"
OPT_ATTR_USECASE = "usecase" OPT_ATTR_USECASE = "usecase"

3
tools/filecsv_fcts.py

@ -199,6 +199,9 @@ class FileFcts(tools.file_abstract.FileFcts):
tableAttr = setTableAttribute(tableAttr, a[0], fields[1], job) tableAttr = setTableAttribute(tableAttr, a[0], fields[1], job)
if ttype == "" and D.DATA_ATTR_TYPE in tableAttr: if ttype == "" and D.DATA_ATTR_TYPE in tableAttr:
ttype = tableAttr[D.DATA_ATTR_TYPE] ttype = tableAttr[D.DATA_ATTR_TYPE]
elif D.DATA_ATTR_TYPE in tableAttr and ttype != tableAttr[D.DATA_ATTR_TYPE]:
msg.logWarn("System-Type " + ttype + " be overwrite by file-Type " + tableAttr[D.DATA_ATTR_TYPE])
ttype = tableAttr[D.DATA_ATTR_TYPE]
continue continue
elif self.isBlock(msg, job, fields[0], D.CSV_BLOCK_HEAD, status): elif self.isBlock(msg, job, fields[0], D.CSV_BLOCK_HEAD, status):
setTdataLine(tdata, fields, D.CSV_BLOCK_HEAD, job) setTdataLine(tdata, fields, D.CSV_BLOCK_HEAD, job)

4
tools/path_const.py

@ -23,8 +23,10 @@ KEY_COMP = "comp"
""" keyword for individual component """ """ keyword for individual component """
KEY_TOOL = "tool" KEY_TOOL = "tool"
""" keyword for technical tools """ """ keyword for technical tools """
VAL_UTIL = "utils" VAL_TOOLS = "tools"
""" subdir for any technical tools """ """ subdir for any technical tools """
VAL_TEST = "test"
""" subdir for any unit-tests """
VAL_CONFIG = "config" VAL_CONFIG = "config"
""" subdir for any place of config-files """ """ subdir for any place of config-files """
VAL_COMPS = "components" VAL_COMPS = "components"

Loading…
Cancel
Save