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 = {}
__instance = None
__writeDB = True
def __init__(self, job):
"""
@ -52,36 +53,6 @@ class Testserver():
if Testserver.__instance == None:
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):
"""
@ -151,13 +122,14 @@ class Testserver():
args["context"] = context
table = model.table.Table(job)
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)
for s in sql.split(";\n"):
if len(s) < 3:
continue
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)
except Exception as e:
raise Exception("Fehler bei createSchema " + s)

2
basic/constants.py

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

2
model/artifact.py

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

2
model/component.py

@ -144,5 +144,3 @@ class Component(model.entity.Entity):
def delete_entity(self, job, name):
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
def getRelease(job=None, name: str="", args: dict={}):
import model.release
return model.release.Release(job, name, args)
import model.prelease
return model.prelease.Release(job, name, args)
def getEnvironment(job=None, name: str="", args: dict={}):
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;;;;;;
;project;string;vchar(256);I;;;;;;
;application;string;vchar(256);N;;;;;;
;release;str;vchar(256);I;;;;;;
;prelease;str;vchar(256);I;;;;;;
;environment;str;vchar(256);N;;;;;;
;status;str;vchar(256);I;;;;;;
;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;;;;;;
;name;str;vchar(256);I;;;;;;
;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.git_tool
TABLE_NAME = "release"
TABLE_NAME = "prelease"
""" system-name for this entity """
FIELD_ID = "rlid"
FILE_EXTENSION = D.DFILE_TYPE_CSV

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

@ -1,6 +1,6 @@
_type;ddl;;;;;;;;;
_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;;;;;;
;stid;int;integer;I;;;T:1;;;
;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.git_tool
TYPE_ADMIN = "admin"
TYPE_CTLG = "catalog"
TABLE_NAME = "table"
""" system-name for this entity """
FIELD_ID = "tbid"
@ -64,6 +67,158 @@ class Table(model.entity.Entity):
LIST_NODES = [B.NODE_ATTRIBUTES, "fielddef", "fieldnames"]
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
name = ""
project = ""
@ -74,7 +229,7 @@ class Table(model.entity.Entity):
self.project = project
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
"""
@ -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])
sqlTable += dbi.getCreateTable(tableName)
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:
if f[0:1] == "_":
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;;;;;;
;project;string;vchar(256);I;;;;;;
;application;string;vchar(256);N;;;;;;
;release;string;vchar(256);I;;;;;;
;prelease;string;vchar(256);I;;;;;;
;reference;str;vchar(256);N;;;;;;story
;attributes;jlob;clob;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):
name = ""
description = ""
release = ""
prelease = ""
testsuites = {}
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;;;;;;
;application;string;vchar(256);N;;;;;;
;reference;str;vchar(256);N;;;;;;
;release;str;vchar(256);I;;;;;;
;prelease;str;vchar(256);I;;;;;;
;environment;str;vchar(256);N;;;;;;
;testplan;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 basic.constants as B
import test.constants as T
import model.release
import model.prelease
import model.entity
import tools.data_const as D
@ -33,9 +33,9 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
release = model.release.Release(job)
prelease = model.prelease.Release(job)
entityNames = []
entityNames = release.read_unique_names(job, "", "", "", {})
entityNames = prelease.read_unique_names(job, "", "", "", {})
self.assertEqual(type(entityNames), list)
#entityNames = project.select_unique_names(job, "", "", "", {})
#self.assertEqual(type(entityNames), list)
@ -48,11 +48,11 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
release = model.release.Release(job)
prelease = model.prelease.Release(job)
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)
#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)
def test_12getEntity(self):
@ -63,15 +63,15 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
release = model.release.Release(job)
prelease = model.prelease.Release(job)
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.assertRaises(Exception, release.read_entity, job, "xyzxyz")
self.assertRaises(Exception, prelease.read_entity, job, "xyzxyz")
#
#actrelease = release.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name)
#self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"])
#actrelease = prelease.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.prelease.FIELD_NAME), name)
#self.assertRaises(Exception, prelease.select_entity, job, ["xyzxyz"])
def test_13writeEntity(self):
global mymsg
@ -91,20 +91,20 @@ class MyTestCase(unittest.TestCase):
return
job = test.testtools.getJob()
username = "hans_xyz"
release = model.release.Release()
entityNames = collectInnerList(release.get_unique_names(job, storage=model.entity.STORAGE_DB))
prelease = model.prelease.Release()
entityNames = collectInnerList(prelease.get_unique_names(job, storage=model.entity.STORAGE_DB))
#self.assertNotIn(username, entityNames)
release.username = username
release.name = "Hans"
release.famname = "im Glueck"
release.project = "TESTPROJ"
#release.insert_entity(job, username, table="release")
entityNames = collectInnerList(release.get_unique_names(job, storage=model.entity.STORAGE_DB))
prelease.username = username
prelease.name = "Hans"
prelease.famname = "im Glueck"
prelease.project = "TESTPROJ"
#prelease.insert_entity(job, username, table="prelease")
entityNames = collectInnerList(prelease.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertIn(username, entityNames)
actUser = release.select_entity(job, username)
self.assertEqual(getattr(actUser, model.release.FIELD_NAME), username)
actUser.delete_entity(job, username, "release")
entityNames = collectInnerList(release.get_unique_names(job, storage=model.entity.STORAGE_DB))
actUser = prelease.select_entity(job, username)
self.assertEqual(getattr(actUser, model.prelease.FIELD_NAME), username)
actUser.delete_entity(job, username, "prelease")
entityNames = collectInnerList(prelease.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertNotIn(username, entityNames)
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.assertRaises(Exception, testsuite.read_entity, job, "xyzxyz")
#
#actrelease = release.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name)
#self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"])
#actrelease = prelease.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.prelease.FIELD_NAME), name)
#self.assertRaises(Exception, prelease.select_entity, job, ["xyzxyz"])
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.assertRaises(Exception, table.read_entity, job, "xyzxyz")
#
#actrelease = release.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name)
#actrelease = prelease.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.prelease.FIELD_NAME), name)
#self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"])
if __name__ == '__main__':

Loading…
Cancel
Save