Ulrich
2 years ago
15 changed files with 633 additions and 47 deletions
|
|
|
@ -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) |
|||
|
@ -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() |
@ -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() |
@ -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…
Reference in new issue