Browse Source

rename release in prelease because it is a keyword in mysql

refactor
Ulrich 1 year ago
parent
commit
15589c9c69
  1. 36
      basic/Testserver.py
  2. 2
      basic/constants.py
  3. 2
      model/artifact.py
  4. 2
      model/component.py
  5. 4
      model/factory.py
  6. 2
      model/job.csv
  7. 2
      model/prelease.csv
  8. 2
      model/prelease.py
  9. 2
      model/st_preleases.csv
  10. 167
      model/table.py
  11. 2
      model/testplan.csv
  12. 2
      model/testplan.py
  13. 2
      model/testreport.csv
  14. 48
      test/test_17release.py
  15. 6
      test/test_26testsuite.py
  16. 4
      test/test_29datatable.py

36
basic/Testserver.py

@ -25,6 +25,7 @@ class Testserver():
""" """
tables = {} tables = {}
__instance = None __instance = None
__writeDB = True
def __init__(self, job): def __init__(self, job):
""" """
@ -52,36 +53,6 @@ class Testserver():
if Testserver.__instance == None: if Testserver.__instance == None:
return Testserver(job) return Testserver(job)
def restInit(self):
if not B.DATA_NODE_DDL in self.conf:
self.conf[B.DATA_NODE_DDL] = {}
for table in COMP_TABLES:
if table in B.LIST_DB_ATTR:
continue
else:
continue
ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, COMP_NAME, table)
tableDdl = model.table.Table(job, component=COMP_NAME, name=table)
self.tables[table] = tableDdl
tddl = {}
tddl[table] = {}
#for k in ddl:
for k in tableDdl.fielddef:
tddl[table][k] = tableDdl.fielddef[k]
tddl[table][B.DATA_NODE_HEADER] = D.LIST_DDL_ATTR
tddl[table][B.DATA_NODE_FIELDS] = tableDdl.fieldnames
tddl[D.DATA_ATTR_TBL] = table
path = "/home/ulrich/workspace/Datest/temp/"+table+".yml"
tools.file_tool.write_file_dict(job.m, job, path, tddl)
path = "/home/ulrich/workspace/Datest/temp/"+table+".csv"
tools.file_tool.write_file_dict(job.m, job, path, tddl, ttype=D.CSV_SPECTYPE_DDL)
if B.DATA_NODE_TABLES in ddl and table in ddl[B.DATA_NODE_TABLES]:
self.conf[B.DATA_NODE_DDL][table] = ddl[B.DATA_NODE_TABLES][table]
elif table in ddl:
self.conf[B.DATA_NODE_DDL][table] = ddl[table]
else:
self.conf[B.DATA_NODE_DDL][table] = ddl
def createAdminDBTables(self, job): def createAdminDBTables(self, job):
""" """
@ -151,13 +122,14 @@ class Testserver():
args["context"] = context args["context"] = context
table = model.table.Table(job) table = model.table.Table(job)
table = table.read_entity(job, tablename, args=args) table = table.read_entity(job, tablename, args=args)
sql = table.get_schema(tablename) # [B.DATA_NODE_TABLES][m[:-4]] sql = table.get_schema(tablename, model.table.TYPE_ADMIN) # [B.DATA_NODE_TABLES][m[:-4]]
job.m.logInfo(sql) job.m.logInfo(sql)
for s in sql.split(";\n"): for s in sql.split(";\n"):
if len(s) < 3: if len(s) < 3:
continue continue
try: try:
#self.dbi.execStatement(s + ";", job.conf[B.TOPIC_NODE_DB]) if self.__writeDB:
self.dbi.execStatement(s + ";", job.conf[B.TOPIC_NODE_DB])
print("SQL executed: " + s) print("SQL executed: " + s)
except Exception as e: except Exception as e:
raise Exception("Fehler bei createSchema " + s) raise Exception("Fehler bei createSchema " + s)

2
basic/constants.py

@ -163,7 +163,7 @@ SUBJECT_USECASE = "usecase"
SUBJECT_USECASES = SUBJECT_USECASE + "s" SUBJECT_USECASES = SUBJECT_USECASE + "s"
SUBJECT_USER = "user" SUBJECT_USER = "user"
SUBJECT_USERS = SUBJECT_USER + "s" SUBJECT_USERS = SUBJECT_USER + "s"
SUBJECT_REL = "release" SUBJECT_REL = "prelease"
SUBJECT_RELS = SUBJECT_REL + "s" SUBJECT_RELS = SUBJECT_REL + "s"
SUBJECT_TESTCASE = "testcase" SUBJECT_TESTCASE = "testcase"
SUBJECT_TESTCASES = SUBJECT_TESTCASE + "s" SUBJECT_TESTCASES = SUBJECT_TESTCASE + "s"

2
model/artifact.py

@ -29,7 +29,7 @@ class Artifact(model.entity.Entity):
LIST_SUBTABLES = [] LIST_SUBTABLES = []
name = "" name = ""
description = "" description = ""
release = "" prelease = ""
testsuites = {} testsuites = {}
steps = [] steps = []

2
model/component.py

@ -144,5 +144,3 @@ class Component(model.entity.Entity):
def delete_entity(self, job, name): def delete_entity(self, job, name):
return return
def get_schema(self, tableName="", tableObject=None):
return

4
model/factory.py

@ -67,8 +67,8 @@ def get_entity_object(job, entityname: str, name: str="", args: dict={}):
return entity return entity
def getRelease(job=None, name: str="", args: dict={}): def getRelease(job=None, name: str="", args: dict={}):
import model.release import model.prelease
return model.release.Release(job, name, args) return model.prelease.Release(job, name, args)
def getEnvironment(job=None, name: str="", args: dict={}): def getEnvironment(job=None, name: str="", args: dict={}):
import model.environment import model.environment

2
model/job.csv

@ -4,7 +4,7 @@ table:job;_field;type;format;index;generic;aggregat;key;acceptance;alias;descrip
;description;string;vchar(256);N;;;;;; ;description;string;vchar(256);N;;;;;;
;project;string;vchar(256);I;;;;;; ;project;string;vchar(256);I;;;;;;
;application;string;vchar(256);N;;;;;; ;application;string;vchar(256);N;;;;;;
;release;str;vchar(256);I;;;;;; ;prelease;str;vchar(256);I;;;;;;
;environment;str;vchar(256);N;;;;;; ;environment;str;vchar(256);N;;;;;;
;status;str;vchar(256);I;;;;;; ;status;str;vchar(256);I;;;;;;
;attributes;jlob;clob;N;;;;;; ;attributes;jlob;clob;N;;;;;;

1 table:job _field type format index generic aggregat key acceptance alias description
4 description string vchar(256) N
5 project string vchar(256) I
6 application string vchar(256) N
7 release prelease str vchar(256) I
8 environment str vchar(256) N
9 status str vchar(256) I
10 attributes jlob clob N

2
model/release.csv → model/prelease.csv

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

2
model/release.py → model/prelease.py

@ -12,7 +12,7 @@ import tools.config_tool
import tools.file_tool import tools.file_tool
import tools.git_tool import tools.git_tool
TABLE_NAME = "release" TABLE_NAME = "prelease"
""" system-name for this entity """ """ system-name for this entity """
FIELD_ID = "rlid" FIELD_ID = "rlid"
FILE_EXTENSION = D.DFILE_TYPE_CSV FILE_EXTENSION = D.DFILE_TYPE_CSV

2
model/st_releases.csv → model/st_preleases.csv

@ -1,6 +1,6 @@
_type;ddl;;;;;;;;; _type;ddl;;;;;;;;;
_key;_field;;;;;;;;; _key;_field;;;;;;;;;
table:st_releases;_field;type;format;index;generic;aggregat;key;acceptance;alias;description table:st_preleases;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;strelid;pk;integer;N;;;;;; ;strelid;pk;integer;N;;;;;;
;stid;int;integer;I;;;T:1;;; ;stid;int;integer;I;;;T:1;;;
;rlid;int;integer;I;;;T:2;;; ;rlid;int;integer;I;;;T:2;;;
1 _type ddl
2 _key _field
3 table:st_preleases _field type format index generic aggregat key acceptance alias description
4 strelid pk integer N
5 stid int integer I T:1
6 rlid int integer I T:2
7 description string vchar(256) N
8 reference str vchar(256) N

167
model/table.py

@ -12,6 +12,9 @@ import tools.config_tool
import tools.file_tool import tools.file_tool
import tools.git_tool import tools.git_tool
TYPE_ADMIN = "admin"
TYPE_CTLG = "catalog"
TABLE_NAME = "table" TABLE_NAME = "table"
""" system-name for this entity """ """ system-name for this entity """
FIELD_ID = "tbid" FIELD_ID = "tbid"
@ -64,6 +67,158 @@ class Table(model.entity.Entity):
LIST_NODES = [B.NODE_ATTRIBUTES, "fielddef", "fieldnames"] LIST_NODES = [B.NODE_ATTRIBUTES, "fielddef", "fieldnames"]
LIST_SUBTABLES = [] LIST_SUBTABLES = []
LIST_ADMINFIELDS = {
"insauthor": {
"_field": "insauthor",
"type": "str",
"format": "varchar(128)",
"index": "N",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
},
"inscommit": {
"_field": "inscommit",
"type": "str",
"format": "varchar(1024)",
"index": "N",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
},
"instime": {
"_field": "instime",
"type": "time",
"format": "time",
"index": "N",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
},
"updauthor": {
"_field": "updauthor",
"type": "str",
"format": "varchar(128)",
"index": "N",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
},
"updcommit": {
"_field": "updcommit",
"type": "str",
"format": "varchar(1024)",
"index": "N",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
},
"updtime": {
"_field": "updtime",
"type": "time",
"format": "time",
"index": "N",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
},
"actual": {
"_field": "actual",
"type": "int",
"format": "int",
"index": "N",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
}
}
# project
# testcase
# artefact :
#
LIST_CATALOGFIELDS = {
"project": {
"_field": "project",
"type": "str",
"format": "varchar(128)",
"index": "I",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
},
"application": {
"_field": "application",
"type": "str",
"format": "varchar(128)",
"index": "I",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
},
"testcase": {
"_field": "testcase",
"type": "str",
"format": "varchar(128)",
"index": "I",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
},
"artifact": {
"_field": "artifact",
"type": "str",
"format": "varchar(128)",
"index": "I",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": "result "
},
"refdate": {
"_field": "refdate",
"type": "time",
"format": "time",
"index": "N",
"generic": "",
"aggregat": "",
"key": "",
"acceptance": "",
"alias": "",
"description": ""
}
}
tbid = 0 tbid = 0
name = "" name = ""
project = "" project = ""
@ -74,7 +229,7 @@ class Table(model.entity.Entity):
self.project = project self.project = project
self.name = name self.name = name
def get_schema(self, tableName="", tableObject=None): def get_schema(self, tableName="", tableType=""):
""" """
gets schema/ddl-informations in order to create the database gets schema/ddl-informations in order to create the database
""" """
@ -84,6 +239,16 @@ class Table(model.entity.Entity):
dbi = basic.toolHandling.getDbTool(self.job, None, self.job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE]) dbi = basic.toolHandling.getDbTool(self.job, None, self.job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE])
sqlTable += dbi.getCreateTable(tableName) sqlTable += dbi.getCreateTable(tableName)
tableId = "" tableId = ""
if tableType in [TYPE_CTLG]:
for f in self.LIST_CATALOGFIELDS.keys():
if f not in self.fieldnames:
self.fieldnames.append(f)
self.fielddef[f] = self.LIST_CATALOGFIELDS[f]
if tableType in [TYPE_ADMIN, TYPE_CTLG]:
for f in self.LIST_ADMINFIELDS.keys():
if f not in self.fieldnames:
self.fieldnames.append(f)
self.fielddef[f] = self.LIST_ADMINFIELDS[f]
for f in self.fieldnames: for f in self.fieldnames:
if f[0:1] == "_": if f[0:1] == "_":
continue continue

2
model/testplan.csv

@ -6,7 +6,7 @@ table:testplan;_field;type;format;index;generic;aggregat;key;acceptance;alias;de
;description;string;vchar(256);N;;;;;; ;description;string;vchar(256);N;;;;;;
;project;string;vchar(256);I;;;;;; ;project;string;vchar(256);I;;;;;;
;application;string;vchar(256);N;;;;;; ;application;string;vchar(256);N;;;;;;
;release;string;vchar(256);I;;;;;; ;prelease;string;vchar(256);I;;;;;;
;reference;str;vchar(256);N;;;;;;story ;reference;str;vchar(256);N;;;;;;story
;attributes;jlob;clob;N;;;;;; ;attributes;jlob;clob;N;;;;;;
;insauthor;str;vchar(256);N;;;;;; ;insauthor;str;vchar(256);N;;;;;;

1 _type ctlg
6 description string vchar(256) N
7 project string vchar(256) I
8 application string vchar(256) N
9 release prelease string vchar(256) I
10 reference str vchar(256) N story
11 attributes jlob clob N
12 insauthor str vchar(256) N

2
model/testplan.py

@ -28,7 +28,7 @@ LIST_SUBTABLES = {
class Testplan(model.entity.Entity): class Testplan(model.entity.Entity):
name = "" name = ""
description = "" description = ""
release = "" prelease = ""
testsuites = {} testsuites = {}
steps = [] steps = []

2
model/testreport.csv

@ -7,7 +7,7 @@ table:testreport;_field;type;format;index;generic;aggregat;key;acceptance;alias;
;project;string;vchar(256);I;;;;;; ;project;string;vchar(256);I;;;;;;
;application;string;vchar(256);N;;;;;; ;application;string;vchar(256);N;;;;;;
;reference;str;vchar(256);N;;;;;; ;reference;str;vchar(256);N;;;;;;
;release;str;vchar(256);I;;;;;; ;prelease;str;vchar(256);I;;;;;;
;environment;str;vchar(256);N;;;;;; ;environment;str;vchar(256);N;;;;;;
;testplan;str;vchar(256);N;;;;;; ;testplan;str;vchar(256);N;;;;;;
;testsuite;str;vchar(256);N;;;;;; ;testsuite;str;vchar(256);N;;;;;;

1 _type ctlg
7 project string vchar(256) I
8 application string vchar(256) N
9 reference str vchar(256) N
10 release prelease str vchar(256) I
11 environment str vchar(256) N
12 testplan str vchar(256) N
13 testsuite str vchar(256) N

48
test/test_17release.py

@ -9,7 +9,7 @@ import inspect
import test.testtools import test.testtools
import basic.constants as B import basic.constants as B
import test.constants as T import test.constants as T
import model.release import model.prelease
import model.entity import model.entity
import tools.data_const as D import tools.data_const as D
@ -33,9 +33,9 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
release = model.release.Release(job) prelease = model.prelease.Release(job)
entityNames = [] entityNames = []
entityNames = release.read_unique_names(job, "", "", "", {}) entityNames = prelease.read_unique_names(job, "", "", "", {})
self.assertEqual(type(entityNames), list) self.assertEqual(type(entityNames), list)
#entityNames = project.select_unique_names(job, "", "", "", {}) #entityNames = project.select_unique_names(job, "", "", "", {})
#self.assertEqual(type(entityNames), list) #self.assertEqual(type(entityNames), list)
@ -48,11 +48,11 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
release = model.release.Release(job) prelease = model.prelease.Release(job)
entityNames = [] entityNames = []
entityNames = release.get_entities(job, storage=model.entity.STORAGE_FILE) entityNames = prelease.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list) self.assertEqual(type(entityNames), list)
#entityNames = release.get_entities(job, storage=model.entity.STORAGE_DB) #entityNames = prelease.get_entities(job, storage=model.entity.STORAGE_DB)
#self.assertEqual(type(entityNames), list) #self.assertEqual(type(entityNames), list)
def test_12getEntity(self): def test_12getEntity(self):
@ -63,15 +63,15 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS: if actfunction not in TEST_FUNCTIONS:
return return
job = test.testtools.getJob() job = test.testtools.getJob()
release = model.release.Release(job) prelease = model.prelease.Release(job)
name = "V-1.1.0" name = "V-1.1.0"
actrelease = release.read_entity(job, name) actrelease = prelease.read_entity(job, name)
self.assertEqual(getattr(actrelease, D.FIELD_NAME), name) self.assertEqual(getattr(actrelease, D.FIELD_NAME), name)
self.assertRaises(Exception, release.read_entity, job, "xyzxyz") self.assertRaises(Exception, prelease.read_entity, job, "xyzxyz")
# #
#actrelease = release.select_entity(job, name) #actrelease = prelease.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name) #self.assertEqual(getattr(actrelease, model.prelease.FIELD_NAME), name)
#self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"]) #self.assertRaises(Exception, prelease.select_entity, job, ["xyzxyz"])
def test_13writeEntity(self): def test_13writeEntity(self):
global mymsg global mymsg
@ -91,20 +91,20 @@ class MyTestCase(unittest.TestCase):
return return
job = test.testtools.getJob() job = test.testtools.getJob()
username = "hans_xyz" username = "hans_xyz"
release = model.release.Release() prelease = model.prelease.Release()
entityNames = collectInnerList(release.get_unique_names(job, storage=model.entity.STORAGE_DB)) entityNames = collectInnerList(prelease.get_unique_names(job, storage=model.entity.STORAGE_DB))
#self.assertNotIn(username, entityNames) #self.assertNotIn(username, entityNames)
release.username = username prelease.username = username
release.name = "Hans" prelease.name = "Hans"
release.famname = "im Glueck" prelease.famname = "im Glueck"
release.project = "TESTPROJ" prelease.project = "TESTPROJ"
#release.insert_entity(job, username, table="release") #prelease.insert_entity(job, username, table="prelease")
entityNames = collectInnerList(release.get_unique_names(job, storage=model.entity.STORAGE_DB)) entityNames = collectInnerList(prelease.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertIn(username, entityNames) self.assertIn(username, entityNames)
actUser = release.select_entity(job, username) actUser = prelease.select_entity(job, username)
self.assertEqual(getattr(actUser, model.release.FIELD_NAME), username) self.assertEqual(getattr(actUser, model.prelease.FIELD_NAME), username)
actUser.delete_entity(job, username, "release") actUser.delete_entity(job, username, "prelease")
entityNames = collectInnerList(release.get_unique_names(job, storage=model.entity.STORAGE_DB)) entityNames = collectInnerList(prelease.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertNotIn(username, entityNames) self.assertNotIn(username, entityNames)
def collectInnerList(inList): def collectInnerList(inList):

6
test/test_26testsuite.py

@ -82,9 +82,9 @@ class MyTestCase(unittest.TestCase):
self.assertEqual(getattr(acttestsuite, model.testsuite.FIELD_NAME), name) self.assertEqual(getattr(acttestsuite, model.testsuite.FIELD_NAME), name)
self.assertRaises(Exception, testsuite.read_entity, job, "xyzxyz") self.assertRaises(Exception, testsuite.read_entity, job, "xyzxyz")
# #
#actrelease = release.select_entity(job, name) #actrelease = prelease.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name) #self.assertEqual(getattr(actrelease, model.prelease.FIELD_NAME), name)
#self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"]) #self.assertRaises(Exception, prelease.select_entity, job, ["xyzxyz"])
if __name__ == '__main__': if __name__ == '__main__':

4
test/test_29datatable.py

@ -66,8 +66,8 @@ class MyTestCase(unittest.TestCase):
self.assertEqual(getattr(acttable, model.datatable.FIELD_NAME), name) self.assertEqual(getattr(acttable, model.datatable.FIELD_NAME), name)
self.assertRaises(Exception, table.read_entity, job, "xyzxyz") self.assertRaises(Exception, table.read_entity, job, "xyzxyz")
# #
#actrelease = release.select_entity(job, name) #actrelease = prelease.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name) #self.assertEqual(getattr(actrelease, model.prelease.FIELD_NAME), name)
#self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"]) #self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"])
if __name__ == '__main__': if __name__ == '__main__':

Loading…
Cancel
Save