Browse Source

some further classes, read-methods

refactor
Ulrich 1 year ago
parent
commit
ed7e74d238
  1. 2
      basic/constants.py
  2. 2
      model/application.csv
  3. 4
      model/application.py
  4. 4
      model/project.py
  5. 7
      model/release.py
  6. 4
      model/step.py
  7. 1
      model/story.csv
  8. 53
      model/story.py
  9. 53
      model/usecase.py
  10. 15
      model/variant.csv
  11. 79
      model/variant.py
  12. 64
      test/test_17release.py
  13. 130
      test/test_17story.py
  14. 131
      test/test_19usecase.py
  15. 131
      test/test_19variant.py

2
basic/constants.py

@ -254,6 +254,8 @@ ATTR_ARTS_FILE = "file"
SUBJECT_PROJECT = "project"
SUBJECT_PROJECTS = SUBJECT_PROJECT+"s"
SUBJECT_ENV = PAR_ENV
SUBJECT_STORY = "story"
SUBJECT_STORIES = "stories"
SUBJECT_CONN = "conn" # | | x | | | conn_tool, db*_tools, cli*_toold
ATTR_TYPE = "type" # | x | x | | x | conn_tool, toolHandling, db*_tools

2
model/application.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:application;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;apid;pk;autoint;N;;;;;;
;name;str;vchar(256);I;;;;;;

1 _type _field ctlg type format index table:application generic aggregat key acceptance description alias
1 _type ctlg
2 _key _field
3 table:application _field _field type type format format index index table:application generic generic aggregat aggregat key key acceptance acceptance alias description alias description
4 apid apid pk pk autoint autoint N N
5 name name str str vchar(256) vchar(256) I I

4
model/application.py

@ -21,10 +21,10 @@ TABLE_NAME = B.SUBJECT_APP
""" system-name for this entity """
FIELD_ID = "apid"
FIELD_NAME = D.FIELD_NAME
FIELD_DISCRIPTION = B.SUBJECT_REFERENCE
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DISCRIPTION, FIELD_REFERENCE, FIELD_PROJECT]
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT]
""" list of object-attributes """
SUB_COMPS = B.SUBJECT_COMPS

4
model/project.py

@ -17,9 +17,9 @@ TABLE_NAME = "project"
""" system-name for this entity """
FIELD_ID = "prid"
FIELD_NAME = "name"
FIELD_DISCRIPTION = B.SUBJECT_REFERENCE
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DISCRIPTION, FIELD_REFERENCE]
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE]
""" list of object-attributes """
FILE_EXTENSION = D.DFILE_TYPE_YML

7
model/release.py

@ -12,16 +12,16 @@ import tools.config_tool
import tools.file_tool
import tools.git_tool
TABLE_NAME = "step"
TABLE_NAME = "release"
""" system-name for this entity """
FIELD_ID = "rlid"
FIELD_NAME = "name"
FIELD_DISCRIPTION = B.SUBJECT_REFERENCE
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
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_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_APPLICATION, FIELD_ATTRIBUTES]
""" list of object-attributes """
LIST_SUBTABLES = []
@ -37,6 +37,7 @@ class Release(model.entity.Entity):
project = ""
application = ""
description = ""
attributes = ""
reference = ""
def __init__(self, job, project, name=""):

4
model/step.py

@ -17,11 +17,11 @@ TABLE_NAME = "step"
""" system-name for this entity """
FIELD_ID = "spid"
FIELD_NAME = "name"
FIELD_DISCRIPTION = B.SUBJECT_REFERENCE
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
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_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_COMPONENT]
""" list of object-attributes """
LIST_SUBTABLES = []

1
model/story.csv

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

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

53
model/story.py

@ -4,12 +4,29 @@
# ---------------------------------------------------------------------------------------------------------
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.git_tool
FIELDS = {
D.OPT_ATTR_STORYID : "story",
D.OPT_ATTR_STORY : "description"
}
TABLE_NAME = "story"
""" system-name for this entity """
FIELD_ID = "stid"
FIELD_NAME = "name"
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, 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 Story(model.entity.Entity):
stid = 0
@ -18,9 +35,35 @@ class Story(model.entity.Entity):
description = ""
reference = ""
def __init__(self, job, project="", name=""):
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
: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_STORIES, tools.config_tool.get_plain_filename(job, ""))
outList = list(config[B.SUBJECT_STORIES][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_STORIES, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES)

53
model/usecase.py

@ -4,6 +4,30 @@
# ---------------------------------------------------------------------------------------------------------
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.git_tool
TABLE_NAME = "uscase"
""" system-name for this entity """
FIELD_ID = "ucid"
FIELD_NAME = "name"
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
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_DESCRIPTION, 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 Usecase(model.entity.Entity):
ucid = 0
@ -12,10 +36,37 @@ class Usecase(model.entity.Entity):
application = ""
description = ""
reference = ""
attributes = ""
def __init__(self, job, project="", name=""):
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
: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_USECASES, tools.config_tool.get_plain_filename(job, ""))
outList = list(config[B.SUBJECT_USECASES][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_USECASES, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES)

15
model/variant.csv

@ -0,0 +1,15 @@
table:step;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;vrid;pk;int;N;;;;;;
;name;str;vchar(256);I;;;;;;
;description;string;vchar(256);N;;;;;;
;reference;str;vchar(256);N;;;;;;
;project;str;vchar(256);N;;;;;;
;component;str;vchar(256);N;;;;;;
;attributes;string;jlob;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:step _field type format index generic aggregat key acceptance alias description
2 vrid pk int 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 component str 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

79
model/variant.py

@ -0,0 +1,79 @@
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import os
import basic.toolHandling
import basic.componentHandling
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.git_tool
TABLE_NAME = "variant"
""" system-name for this entity """
FIELD_ID = "vrid"
FIELD_NAME = "name"
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_COMPONENT = B.SUBJECT_COMP
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_COMPONENT, FIELD_ATTRIBUTES]
""" 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 """
class Variant(model.entity.Entity):
name = ""
description = ""
reference = ""
attributes = ""
project = ""
component = ""
def __init__(self, job, project, name=""):
"""
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:
"""
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_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)

64
test/test_17release.py

@ -1,9 +1,11 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
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
@ -62,12 +64,12 @@ class MyTestCase(unittest.TestCase):
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.assertEqual(getattr(actrelease, model.release.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"])
#actrelease = release.select_entity(job, name)
#self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name)
#self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"])
def test_13writeEntity(self):
global mymsg
@ -78,20 +80,20 @@ class MyTestCase(unittest.TestCase):
return
job = test.testtools.getJob()
username = "hans_xyz"
project = model.project.Project()
entityNames = project.get_unique_names(job, storage=model.entity.STORAGE_FILE)
release = model.release.Release()
entityNames = release.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)
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 = project.read_entity(job, username)
self.assertEquals(getattr(actUser, model.project.FIELD_USERNAME), username)
actUser = release.read_entity(job, username)
self.assertEquals(getattr(actUser, model.release.FIELD_NAME), username)
actUser.remove_entity(job, username)
entityNames = project.get_unique_names(job, storage=model.entity.STORAGE_FILE)
entityNames = release.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
def test_14insertEntity(self):
@ -103,20 +105,20 @@ class MyTestCase(unittest.TestCase):
return
job = test.testtools.getJob()
username = "hans_xyz"
project = model.project.Project()
entityNames = collectInnerList(project.get_unique_names(job, storage=model.entity.STORAGE_DB))
release = model.release.Release()
entityNames = collectInnerList(release.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))
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))
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))
actUser = release.select_entity(job, username)
self.assertEquals(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))
self.assertNotIn(username, entityNames)
def collectInnerList(inList):

130
test/test_17story.py

@ -0,0 +1,130 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import unittest
import inspect
import test.testtools
import basic.constants as B
import test.constants as T
import model.story
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()
story = model.story.Story(job, "TESTPROJ")
entityNames = story.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()
story = model.story.Story(job, "TESTPROJ")
entityNames = []
entityNames = story.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
#entityNames = story.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()
story = model.story.Story(job, "TESTPROJ")
name = "S-1"
actstory = story.read_entity(job, name)
self.assertEqual(getattr(actstory, model.story.FIELD_NAME), name)
self.assertRaises(Exception, story.read_entity, job, "xyzxyz")
#
#actstory = story.select_entity(job, name)
#self.assertEqual(getattr(actstory, model.story.FIELD_NAME), name)
#self.assertRaises(Exception, story.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"
story = model.story.Project()
entityNames = story.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
story.username = username
story.name = "Hans"
story.famname = "im Glueck"
story.project = "TESTPROJ"
story.write_entity(job, username)
entityNames = story.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertIn(username, entityNames)
actUser = story.read_entity(job, username)
self.assertEquals(getattr(actUser, model.story.FIELD_NAME), username)
actUser.remove_entity(job, username)
entityNames = story.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"
story = model.story.Project()
entityNames = collectInnerList(story.get_unique_names(job, storage=model.entity.STORAGE_DB))
#self.assertNotIn(username, entityNames)
story.username = username
story.name = "Hans"
story.famname = "im Glueck"
story.project = "TESTPROJ"
#story.insert_entity(job, username, table="story")
entityNames = collectInnerList(story.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertIn(username, entityNames)
actUser = story.select_entity(job, username)
self.assertEquals(getattr(actUser, model.story.FIELD_NAME), username)
actUser.delete_entity(job, username, "story")
entityNames = collectInnerList(story.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()

131
test/test_19usecase.py

@ -0,0 +1,131 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import unittest
import inspect
import test.testtools
import basic.constants as B
import test.constants as T
import model.usecase
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()
usecase = model.usecase.Usecase(job, "TESTPROJ")
entityNames = []
entityNames = usecase.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()
usecase = model.usecase.Usecase(job, "TESTPROJ")
entityNames = []
entityNames = usecase.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
#entityNames = usecase.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()
usecase = model.usecase.Usecase(job, "TESTPROJ")
name = "AWF-1"
actusecase = usecase.read_entity(job, name)
self.assertEqual(getattr(actusecase, model.usecase.FIELD_NAME), name)
self.assertRaises(Exception, usecase.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()

131
test/test_19variant.py

@ -0,0 +1,131 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import unittest
import inspect
import test.testtools
import basic.constants as B
import test.constants as T
import model.variant
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()
variant = model.variant.Variant(job, "TESTPROJ")
entityNames = []
entityNames = variant.read_unique_names(job, "", "", "", {})
self.assertEqual(type(entityNames), list)
#entityNames = variant.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()
variant = model.variant.Variant(job, "TESTPROJ")
entityNames = []
entityNames = variant.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
#entityNames = variant.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()
variant = model.variant.Variant(job, "TESTPROJ")
name = "xml-rest"
actrelease = variant.read_entity(job, name)
self.assertEqual(getattr(actrelease, model.variant.FIELD_NAME), name)
self.assertRaises(Exception, variant.read_entity, job, "xyzxyz")
#
#actvariant = variant.select_entity(job, name)
#self.assertEqual(getattr(actvariant, model.variant.FIELD_USERNAME), name)
#self.assertRaises(Exception, variant.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"
variant = model.variant.Variant(job, "TESTPROJ")
entityNames = variant.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertNotIn(username, entityNames)
variant.username = username
variant.name = "Hans"
variant.famname = "im Glueck"
variant.project = "TESTPROJ"
variant.write_entity(job, username)
entityNames = variant.get_unique_names(job, storage=model.entity.STORAGE_FILE)
self.assertIn(username, entityNames)
actUser = variant.read_entity(job, username)
self.assertEquals(getattr(actUser, model.variant.FIELD_NAME), username)
actUser.remove_entity(job, username)
entityNames = variant.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"
variant = model.variant.Variant(job, "TESTPROJ")
entityNames = collectInnerList(variant.get_unique_names(job, storage=model.entity.STORAGE_DB))
#self.assertNotIn(username, entityNames)
variant.username = username
variant.name = "Hans"
variant.famname = "im Glueck"
variant.project = "TESTPROJ"
#variant.insert_entity(job, username, table="variant")
entityNames = collectInnerList(variant.get_unique_names(job, storage=model.entity.STORAGE_DB))
self.assertIn(username, entityNames)
actUser = variant.select_entity(job, username)
self.assertEquals(getattr(actUser, model.variant.FIELD_NAME), username)
actUser.delete_entity(job, username, "variant")
entityNames = collectInnerList(variant.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()
Loading…
Cancel
Save