diff --git a/basic/constants.py b/basic/constants.py index ecded85..828154c 100644 --- a/basic/constants.py +++ b/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 diff --git a/model/application.csv b/model/application.csv index 860899a..30fdd91 100644 --- a/model/application.csv +++ b/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;;;;;; diff --git a/model/application.py b/model/application.py index 8db1411..fff4fd4 100644 --- a/model/application.py +++ b/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 diff --git a/model/project.py b/model/project.py index e17b4c4..fdd8552 100644 --- a/model/project.py +++ b/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 diff --git a/model/release.py b/model/release.py index e083e8e..50a43e8 100644 --- a/model/release.py +++ b/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=""): diff --git a/model/step.py b/model/step.py index 3013d8a..5b1a2f2 100644 --- a/model/step.py +++ b/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 = [] diff --git a/model/story.csv b/model/story.csv index cecc0e0..d512930 100644 --- a/model/story.csv +++ b/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;;;;;; diff --git a/model/story.py b/model/story.py index 5a817ae..48d2c13 100644 --- a/model/story.py +++ b/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) + diff --git a/model/usecase.py b/model/usecase.py index 00b8108..aa31519 100644 --- a/model/usecase.py +++ b/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) + diff --git a/model/variant.csv b/model/variant.csv new file mode 100644 index 0000000..d4de365 --- /dev/null +++ b/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;;;;;; diff --git a/model/variant.py b/model/variant.py new file mode 100644 index 0000000..21c36ee --- /dev/null +++ b/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) + diff --git a/test/test_17release.py b/test/test_17release.py index 6672983..5aade5a 100644 --- a/test/test_17release.py +++ b/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): diff --git a/test/test_17story.py b/test/test_17story.py new file mode 100644 index 0000000..a769594 --- /dev/null +++ b/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() diff --git a/test/test_19usecase.py b/test/test_19usecase.py new file mode 100644 index 0000000..eb3a911 --- /dev/null +++ b/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() diff --git a/test/test_19variant.py b/test/test_19variant.py new file mode 100644 index 0000000..989c41d --- /dev/null +++ b/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()