Browse Source

refactor model and test

refactor
Ulrich 1 year ago
parent
commit
351962f1de
  1. 4
      basic/Testserver.py
  2. 2
      basic/connection.py
  3. 141
      model/application.py
  4. 8
      model/entity.py
  5. 9
      model/factory.py
  6. 9
      model/project.py
  7. 8
      model/release.py
  8. 8
      model/story.py
  9. 2
      model/table.py
  10. 8
      model/user.py
  11. 4
      test/test_14table.py
  12. 12
      test/test_15user.py
  13. 33
      test/test_16project.py
  14. 27
      test/test_17release.py
  15. 15
      test/test_17story.py
  16. 13
      test/test_20application.py
  17. 2
      test/test_90testserver.py
  18. 17
      tools/db_abstract.py
  19. 27
      tools/dbmysql_tool.py
  20. 3
      tools/job_tool.py
  21. 3
      unit_tester.py

4
basic/Testserver.py

@ -9,6 +9,7 @@ import tools.data_const as D
import tools.file_tool
import tools.filecsv_fcts
import model.table
import model.factory
import tools.value_tool
import tools.data_tool
@ -20,6 +21,7 @@ COMP_TABLES = ["application", "ap_component", "ap_project", "ap_application",
class Testserver():
"""
the Testserver represents the workspace with all resources for the automation
"""
tables = {}
def __init__(self, job):
@ -39,7 +41,7 @@ class Testserver():
# TODO was muss auf dem Testserver initial geladen werden?
self.model = {}
for s in B.LIST_SUBJECTS:
self.model[tools.data_tool.getSingularKeyword(s)] = {}
self.model[tools.data_tool.getSingularKeyword(s)] = model.factory.get_entity_object(job, s, {})
def restInit(self):
if not B.DATA_NODE_DDL in self.conf:

2
basic/connection.py

@ -5,7 +5,7 @@
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import basic.toolHandling
import utils.data_const as D
import tools.data_const as D
import basic.constants as B
import model.entity

141
model/application.py

@ -5,6 +5,7 @@
print("is importing module.app")
import os
import basic.program
import basic.toolHandling
import basic.constants as B
import model.entity
@ -232,14 +233,16 @@ def insertEntities(job,applData, dbTime, dbi):
class Application(model.entity.Entity):
table = "application"
""" table = "application"
job = None
name = ""
description = ""
reference = ""
components = {}
project = {}
"""
def __int__(self, job, project=""):
def __init__(self, job):
self.job = job
def read_unique_names(self, job, project, application, gran, args):
@ -300,137 +303,3 @@ class Application(model.entity.Entity):
:return:
"""
return self.name
class Application_old(model.entity.Entity):
table = "application"
name = ""
description = ""
reference = ""
component = []
project = {}
def __init__(self, job, name=""):
"""
to be initialized by readSpec
:param job:
"""
self.job = job
if len(name) > 1:
self.getEntity(job, name)
def getEntity(self, job, name):
if B.TOPIC_NODE_DB in job.conf:
self.select_entity(job, name)
#self.read_entity(job, name)
else:
self.read_entity(job, name)
def read_entity(self, job, app):
apppath = tools.config_tool.select_config_path(job, P.KEY_BASIC, B.SUBJECT_APPS, "")
repopath = apppath[len(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS]) + 1:]
gitresult = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, repopath, 1)
applData = tools.config_tool.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS)
# main object
for f in job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[0]][B.DATA_NODE_HEADER]:
if f == model.entity.ENTITY_NAME:
setattr(self, f, app)
elif f == model.entity.ENTITY_ATTRIBUTES:
setattr(self, f, {})
elif f in applData[B.SUBJECT_APPS][app]:
setattr(self, f, applData[B.SUBJECT_APPS][app][f])
elif f in model.entity.ENTITY_FIELDS:
setattr(self, f, model.entity.getEntityValue(job, f, gitresult[0]))
else:
setattr(self, f, "xx")
project = {}
if applData[B.SUBJECT_APPS][app][B.SUBJECT_PROJECTS] is not None:
for proj in applData[B.SUBJECT_APPS][app][B.SUBJECT_PROJECTS]:
project[proj] = {}
for f in job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[1]][B.DATA_NODE_HEADER]:
if f == model.entity.ENTITY_NAME:
project[proj][f] = proj
elif f == "project":
project[proj][f] = proj
elif f == model.entity.ENTITY_ATTRIBUTES:
project[proj][f] = {}
elif f in applData[B.SUBJECT_PROJECTS][proj]:
project[proj][f] = applData[B.SUBJECT_PROJECTS][proj][f]
elif f in model.entity.ENTITY_FIELDS:
project[proj][f] = model.entity.getEntityValue(job, f, gitresult[0])
else:
project[proj][f] = "xx"
setattr(self, "project", project)
component = []
if applData[B.SUBJECT_APPS][app][B.SUBJECT_COMPS] is not None:
for comp in applData[B.SUBJECT_APPS][app][B.SUBJECT_COMPS]:
component.append(comp)
setattr(self, "component", component)
def getApplicationRows(self, job):
rows = []
row = {}
for f in job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[0]][B.DATA_NODE_HEADER]:
row[f] = getattr(self, f)
rows.append(row)
return rows
def getAppProjectRows(self, job, apid):
rows = []
for proj in self.project:
row = {}
for f in job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[1]][B.DATA_NODE_HEADER]:
if f == "apid":
row[f] = apid
elif f in self.project[proj]:
row[f] = self.project[proj][f]
rows.append(row)
return rows
def getAppComponentRows(self, job, apid):
rows = []
for comp in self.component:
row = {}
row["apid"] = apid
row["component"] = comp
rows.append(row)
return rows
def select_entity(self, job, app):
dbi = basic.toolHandling.getDbTool(job, job.testserver, job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE])
data = dbi.selectRows(TABLE_NAMES[0], job, "WHERE name = \'" + app +"\' AND actual = " + model.entity.ENTITY_ACTUAL)
# main object
self.setAppRow(data[B.DATA_NODE_DATA][0], app)
apid = getattr(self, "apid")
data = dbi.selectRows(TABLE_NAMES[1], job, "WHERE apid = "+str(apid))
self.setProjRow(data[B.DATA_NODE_DATA])
data = dbi.selectRows(TABLE_NAMES[2], job, "WHERE apid = " + str(apid))
self.setCompRow(data[B.DATA_NODE_DATA])
def setAppRow(self, row, app):
for f in self.job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[0]][B.DATA_NODE_HEADER]:
if f not in row and f == model.entity.ENTITY_NAME:
setattr(self, f, app)
else:
setattr(self, f, str(row[f]))
def setProjRow(self, rows):
project = {}
for row in rows:
project[row["project"]] = row
setattr(self, "project", project)
def setCompRow(self, rows):
component = []
for row in rows:
component.append(row["component"])
setattr(self, "component", component)
def insertEntity(self, dbi=None):
job = self.job
rows = self.getApplicationRows(job)
apid = dbi.insertRows(job, TABLE_NAMES[0], rows)
rows = self.getAppProjectRows(job, apid)
dbi.insertRows(job, TABLE_NAMES[1], rows)
rows = self.getAppComponentRows(job, apid)
dbi.insertRows(job, TABLE_NAMES[2], rows)
def writeEntity(self):
pass

8
model/entity.py

@ -55,10 +55,10 @@ def getEntityValue(job, field, gitcommit):
class Entity:
def __int__(self, job):
def __init__(self, job, name=""):
self.job = job
self.table = ""
self.testserver = None
if len(name) > 1:
self.getEntity(job, name)
def get_unique_names(self, job, storage="", project="", application="", gran="", args={}):
"""
@ -314,6 +314,8 @@ class Entity:
verify = False
if not job is None:
self.job = job
if rootname not in config:
return self
for k in fields + nodes:
key = tools.data_tool.getExistKeyword(k, config[rootname])
if verify: print("setFields " + k + " / " + key)

9
model/factory.py

@ -2,6 +2,7 @@ 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:
@ -13,7 +14,7 @@ def get_entity_object(job, name, args):
elif name in B.SUBJECT_USECASES:
entity = getUsecase(job)
elif name in B.SUBJECT_PROJECTS:
entity = getApplication(job)
entity = getProject(job)
elif name in B.SUBJECT_APPS:
entity = getApplication(job)
elif name in B.SUBJECT_COMPS:
@ -33,9 +34,9 @@ def getEnvironment(job=None):
import model.environment
return model.environment.Environment(job)
def getApplication(job=None, name=""):
def getApplication(job=None, args={}, name=""):
import model.application
return model.application.Application()
return model.application.Application(job)
def getProject(job=None, name=""):
import model.project
@ -63,7 +64,7 @@ def getStep(job=None, project="", name=""):
def getStory(job=None, project="", name=""):
import model.story
return model.story.Story(job, project, name)
return model.story.Story(job, name)
def getUsecase(job=None, project="", name=""):
import model.usecase

9
model/project.py

@ -35,11 +35,6 @@ class Project(model.entity.Entity):
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
@ -174,14 +169,14 @@ class Project(model.entity.Entity):
:return:
"""
config = {}
config[model.user.TABLE_NAME] = {}
config[model.project.TABLE_NAME] = {}
pathname = os.path.join(job.conf[B.TOPIC_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, "")
config[model.project.TABLE_NAME][k] = getattr(self, k, "")
tools.file_tool.write_file_dict(job.m, job, pathname, config)
return self

8
model/release.py

@ -41,14 +41,6 @@ class Release(model.entity.Entity):
attributes = ""
reference = ""
def __init__(self, job, project, name=""):
"""
to be initialized by readSpec
:param job:
"""
self.job = job
self.project = project
def read_unique_names(self, job, project, application, gran, args):
"""
reads the entity-names from file-storage

8
model/story.py

@ -36,14 +36,6 @@ class Story(model.entity.Entity):
description = ""
reference = ""
def __init__(self, job, project, name=""):
"""
to be initialized by readSpec
:param job:
"""
self.job = job
self.project = project
def read_unique_names(self, job, project, application, gran, args):
"""
reads the entity-names from file-storage

2
model/table.py

@ -75,7 +75,7 @@ class Table(model.entity.Entity):
fieldnames = []
fielddef = {}
def __init__(self, job, project="", name=""):
def __init__(self, job, project="", application="", component=None, name=""):
"""
to be initialized
:param job:

8
model/user.py

@ -44,7 +44,7 @@ class User(model.entity.Entity):
project = ""
role = ""
def __int__(self, job, name=""):
def xx__init__(self, job, name=""):
self.job = job
if len(name) > 1:
self.getEntity(job, name)
@ -258,9 +258,13 @@ class User(model.entity.Entity):
self.setDbAttributes(job, [TABLE_NAME])
dbi = basic.toolHandling.getDbTool(job, self, job.conf[B.TOPIC_NODE_DB]["type"])
condition = "where"
if B.DATA_NODE_KEYS in self.conf[B.DATA_NODE_DDL][table]:
keys = self.conf[B.DATA_NODE_DDL][table][B.DATA_NODE_KEYS]
else:
keys = self.conf[B.DATA_NODE_DDL][table]
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, ""))
val = dbi.getDbValue(keys[f], getattr(self, f, ""))
condition += " and " + f + " = " + val + ""
condition = condition.replace("where and", "where ")
dbi.deleteRows(job, table, condition)

4
test/test_14table.py

@ -15,9 +15,9 @@ 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_14insertEntity", # "test_13writeEntity",
"test_20getSchema"]
TEST_FUNCTIONS = ["test_20getSchema"]
#TEST_FUNCTIONS = ["test_11getEntities"]
PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase):

12
test/test_15user.py

@ -16,7 +16,7 @@ HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10getEntityNames", "test_11getEntities", "test_12getEntity",
"test_13writeEntity", "test_14insertEntity"]
TEST_FUNCTIONS = ["test_14insertEntity"]
# TEST_FUNCTIONS = ["test_14insertEntity"]
PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase):
@ -31,7 +31,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
user = model.user.User()
user = model.user.User(job)
entityNames = []
entityNames = user.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
@ -46,7 +46,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
user = model.user.User()
user = model.user.User(job)
entityNames = []
entityNames = user.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
@ -61,7 +61,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
user = model.user.User()
user = model.user.User(job)
name = "ulrich"
actUser = user.read_entity(job, name)
self.assertEqual(getattr(actUser, model.user.FIELD_USERNAME), name)
@ -80,7 +80,7 @@ class MyTestCase(unittest.TestCase):
return
job = test.testtools.getJob()
username = "hans_xyz"
user = model.user.User()
user = model.user.User(job)
entityNames = user.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
user.username = username
@ -105,7 +105,7 @@ class MyTestCase(unittest.TestCase):
return
job = test.testtools.getJob()
username = "hans_xyz"
user = model.user.User()
user = model.user.User(job)
entityNames = collectInnerList(user.get_unique_names(job, storage=model.entity.STORAGE_DB))
#self.assertNotIn(username, entityNames)
user.username = username

33
test/test_16project.py

@ -13,8 +13,9 @@ 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"]
"test_13writeEntity" #, "test_14insertEntity"
]
#TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity"]
PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase):
@ -29,7 +30,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
project = model.project.Project()
project = model.project.Project(job)
entityNames = []
entityNames = project.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
@ -44,12 +45,12 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
project = model.project.Project()
project = model.project.Project(job)
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)
#entityNames = project.get_entities(job, storage=model.entity.STORAGE_DB)
#self.assertEqual(type(entityNames), list)
def test_12getEntity(self):
global mymsg
@ -59,7 +60,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
project = model.project.Project()
project = model.project.Project(job)
name = "TESTPROJ"
actproject = project.read_entity(job, name)
self.assertEqual(getattr(actproject, model.project.FIELD_NAME), name)
@ -77,22 +78,6 @@ class MyTestCase(unittest.TestCase):
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
@ -103,7 +88,7 @@ class MyTestCase(unittest.TestCase):
return
job = test.testtools.getJob()
username = "hans_xyz"
project = model.project.Project()
project = model.project.Project(job)
entityNames = collectInnerList(project.get_unique_names(job, storage=model.entity.STORAGE_DB))
#self.assertNotIn(username, entityNames)
project.username = username

27
test/test_17release.py

@ -15,8 +15,9 @@ 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"]
"test_13writeEntity" #, "test_14insertEntity"
]
# TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity"]
PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase):
@ -31,7 +32,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
release = model.release.Release(job, "TESTPROJ")
release = model.release.Release(job)
entityNames = []
entityNames = release.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
@ -46,7 +47,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
release = model.release.Release(job, "TESTPROJ")
release = model.release.Release(job)
entityNames = []
entityNames = release.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
@ -61,7 +62,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
release = model.release.Release(job, "TESTPROJ")
release = model.release.Release(job)
name = "V-1.1.0"
actrelease = release.read_entity(job, name)
self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name)
@ -79,22 +80,6 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
username = "hans_xyz"
release = model.release.Release()
entityNames = release.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
release.username = username
release.name = "Hans"
release.famname = "im Glueck"
release.project = "TESTPROJ"
release.write_entity(job, username)
entityNames = release.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertIn(username, entityNames)
actUser = release.read_entity(job, username)
self.assertEquals(getattr(actUser, model.release.FIELD_NAME), username)
actUser.remove_entity(job, username)
entityNames = release.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
def test_14insertEntity(self):
global mymsg

15
test/test_17story.py

@ -14,9 +14,10 @@ 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"]
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):
@ -31,7 +32,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
story = model.story.Story(job, "TESTPROJ")
story = model.story.Story(job)
entityNames = story.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
#entityNames = project.select_unique_names(job, "", "", "", {})
@ -45,7 +46,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
story = model.story.Story(job, "TESTPROJ")
story = model.story.Story(job)
entityNames = []
entityNames = story.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
@ -60,7 +61,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
story = model.story.Story(job, "TESTPROJ")
story = model.story.Story(job)
name = "S-1"
actstory = story.read_entity(job, name)
self.assertEqual(getattr(actstory, model.story.FIELD_NAME), name)
@ -79,7 +80,7 @@ class MyTestCase(unittest.TestCase):
return
job = test.testtools.getJob()
username = "hans_xyz"
story = model.story.Project()
story = model.story.Story(job)
entityNames = story.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
story.username = username

13
test/test_20application.py

@ -13,8 +13,9 @@ import model.application
HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity", "test_11getEntities", "test_10getApplications"]
TEST_FUNCTIONS = ["test_11getEntities"]
TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity", "test_11getEntities" # , "test_10getApplications"
]
#TEST_FUNCTIONS = ["test_11getEntities"]
PROGRAM_NAME = "clean_workspace"
@ -29,7 +30,9 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
application = model.application.Application()
assert isinstance(job, object)
print(str(model.application.Application))
application = model.application.Application(job)
entityNames = []
entityNames = application.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
@ -45,7 +48,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
application = model.application.Application()
application = model.application.Application(job) #.application.Application(job)
entityNames = application.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
#entityNames = environment.get_entities(job, storage=model.entity.STORAGE_DB)
@ -59,7 +62,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
application = model.application.Application()
application = model.application.Application(job)
name = "TESTAPP"
actproject = application.read_entity(job, name)
self.assertEqual(getattr(actproject, model.application.FIELD_NAME), name)

2
test/test_90testserver.py

@ -11,7 +11,7 @@ import basic.constants as B
# the list of TEST_FUNCTIONS defines which function will be really tested.
# if you minimize the list you can check the specific test-function
#TEST_FUNCTIONS = ["test_01createTestserver", "test_02getDBSchema", "test_11createDBTables", "test_11syncApplication"]
TEST_FUNCTIONS = ["test_01createTestserver", "test_02getDBSchema", "test_11createDBTables", "test_11syncApplication"]
TEST_FUNCTIONS = ["test_02getDBSchema"]
# with this variable you can switch prints on and off
verbose = False

17
tools/db_abstract.py

@ -473,9 +473,16 @@ class DbFcts():
return "idx_"+table+"_"+attr
def getInsertFields(self, ddl):
header = []
for f in ddl[B.DATA_NODE_HEADER]:
if D.DDL_TYPE in ddl[f] and ddl[f][D.DDL_TYPE] == D.TYPE_PK:
outheader = []
if B.DATA_NODE_KEYS in ddl:
header = ddl[B.DATA_NODE_KEYS].keys()
keys = ddl[B.DATA_NODE_KEYS]
else:
header = ddl[B.DATA_NODE_HEADER]
keys = ddl
for f in header:
#for f in ddl[B.DATA_NODE_HEADER]:
if D.DDL_TYPE in keys[f] and keys[f][D.DDL_TYPE] == D.TYPE_PK:
continue
header.append(f)
return header
outheader.append(f)
return outheader

27
tools/dbmysql_tool.py

@ -4,6 +4,8 @@
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import traceback
import tools.config_tool
import tools.dbrel_tool
import mysql.connector
@ -32,8 +34,12 @@ class DbFcts(tools.dbrel_tool.DbFcts):
sql += ";"
self.comp.m.logInfo(sql)
connector = self.getConnector()
try:
mycursor = connector.cursor()
mycursor.execute(sql)
except Exception as e:
print("except "+str(e))
print("except " + traceback.format_exc())
myresult = mycursor.fetchall()
tdata[B.DATA_NODE_HEADER] = []
for f in self.comp.conf[B.DATA_NODE_DDL][table][B.DATA_NODE_HEADER]:
@ -42,14 +48,17 @@ class DbFcts(tools.dbrel_tool.DbFcts):
for x in myresult:
r = {}
i = 0
for f in self.comp.conf[B.DATA_NODE_DDL][table][B.DATA_NODE_HEADER]:
try:
if self.comp.conf[B.DATA_NODE_DDL][table][f][D.DDL_TYPE] in [D.TYPE_TIME, D.TYPE_DATE]:
if B.DATA_NODE_KEYS in self.comp.conf[B.DATA_NODE_DDL][table]:
header = self.comp.conf[B.DATA_NODE_DDL][table][B.DATA_NODE_KEYS].keys()
keys = self.comp.conf[B.DATA_NODE_DDL][table][B.DATA_NODE_KEYS]
else:
header = self.comp.conf[B.DATA_NODE_DDL][table][B.DATA_NODE_HEADER]
keys = self.comp.conf[B.DATA_NODE_DDL][table]
for f in header:
if (keys[f][D.DDL_TYPE] in [D.TYPE_TIME, D.TYPE_DATE]):
r[f] = tools.date_tool.getFormatdate(x[i], tools.date_tool.F_DIR)
else:
r[f] = str(x[i])
except:
pass
i += 1
tdata[B.DATA_NODE_DATA].append(r)
self.comp.m.logInfo(str(tdata))
@ -88,14 +97,18 @@ class DbFcts(tools.dbrel_tool.DbFcts):
sql += " VALUES "
self.comp.m.logInfo(sql)
values = []
if B.DATA_NODE_KEYS in self.comp.conf[B.DATA_NODE_DDL][table]:
keys = self.comp.conf[B.DATA_NODE_DDL][table][B.DATA_NODE_KEYS]
else:
keys = self.comp.conf[B.DATA_NODE_DDL][table]
for r in rows:
rowvalues = []
for h in insheader:
if (h in r):
#rowvalues.append("\'"+self.getDbValue(self.comp.conf[B.DATA_NODE_DDL][table][h], r[h])+"\'")
rowvalues.append(self.getDbValue(self.comp.conf[B.DATA_NODE_DDL][table][h], r[h]))
rowvalues.append(self.getDbValue(keys[h], r[h]))
else:
rowvalues.append(self.getDbValue(self.comp.conf[B.DATA_NODE_DDL][table][h], ""))
rowvalues.append(self.getDbValue(keys[h], ""))
sql += "("+",".join(rowvalues)+"), "
values.append(tuple(rowvalues))
sql = sql[0:-2]

3
tools/job_tool.py

@ -177,6 +177,9 @@ def start_child_process(job, args):
elif args[B.PAR_PROGRAM] == "clean_workspace":
import clean_workspace
clean_workspace.startPyJob(childJob)
elif args[B.PAR_PROGRAM] == "unit_tester":
import unit_tester
unit_tester.startPyJob(childJob)
else:
raise Exception("unkown program {}".format(args[B.PAR_PROGRAM]))
childJob.stopJob(1)

3
unit_tester.py

@ -42,7 +42,8 @@ def create_test_suite(job):
testnum = t[len(testdir)+11:len(testdir)+13]
if not testnum.isnumeric():
continue
if testnum not in ["01", "03", "07", "08", "10", "11", "20", "21"]:
if testnum not in ["01", "03", "07", "08", "10", "11", "14", "15", "16", "17", "19",
"20", "21", "22", "26", "27", "28", "29" ]:
continue
if testdir == T.COMP_PATH:
v = "components.test." + t[len(testdir) + 6:-3]

Loading…
Cancel
Save