Ulrich
2 years ago
23 changed files with 518 additions and 83 deletions
|
@ -0,0 +1,42 @@ |
|||
# --------------------------------------------------------------------------------------------------------- |
|||
# Author : Ulrich Carmesin |
|||
# Source : gitea.ucarmesin.de |
|||
# --------------------------------------------------------------------------------------------------------- |
|||
import basic.constants as B |
|||
import model.entity |
|||
|
|||
FIELD_ID = "dtid" |
|||
FIELD_NAME = "name" |
|||
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION |
|||
FIELD_REFERENCE = B.SUBJECT_REFERENCE |
|||
FIELD_COMPONENT = B.SUBJECT_COMP |
|||
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES |
|||
FIELD_HEADER = "" |
|||
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_COMPONENT] |
|||
LIST_NODES = [B.DATA_NODE_HEADER, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS] |
|||
|
|||
LIST_SUBTABLES = {} |
|||
|
|||
class Datatable(model.entity.Entity): |
|||
dcid = 0 |
|||
document = "" |
|||
description = "" |
|||
project = "" |
|||
reference = "" |
|||
|
|||
def __init__(self, job, project="", name=""): |
|||
""" |
|||
to be initialized by readSpec |
|||
:param job: |
|||
""" |
|||
self.job = job |
|||
|
|||
def getFieldList(self): |
|||
return LIST_FIELDS |
|||
|
|||
def getNodeList(self): |
|||
return LIST_NODES |
|||
|
|||
def getSubtableList(self): |
|||
return LIST_SUBTABLES |
|||
|
@ -1,20 +0,0 @@ |
|||
# --------------------------------------------------------------------------------------------------------- |
|||
# Author : Ulrich Carmesin |
|||
# Source : gitea.ucarmesin.de |
|||
# --------------------------------------------------------------------------------------------------------- |
|||
import basic.constants as B |
|||
import model.entity |
|||
|
|||
class Document(model.entity.Entity): |
|||
dcid = 0 |
|||
document = "" |
|||
description = "" |
|||
project = "" |
|||
reference = "" |
|||
|
|||
def __init__(self, job, project="", name=""): |
|||
""" |
|||
to be initialized by readSpec |
|||
:param job: |
|||
""" |
|||
self.job = job |
@ -0,0 +1,72 @@ |
|||
# --------------------------------------------------------------------------------------------------------- |
|||
# Author : Ulrich Carmesin |
|||
# Source : gitea.ucarmesin.de |
|||
# --------------------------------------------------------------------------------------------------------- |
|||
""" |
|||
spontanes Fliegengewicht, das aus einer der folgenden Contexte gebodlet wird. |
|||
step: |
|||
hier als umzusetzende Technik |
|||
artefact: |
|||
hier als umzusetzende Technik bei init oder collect |
|||
component: |
|||
als Superklasse zwecks Ererben fehlernder Attribute |
|||
environment: |
|||
als Superklasse zwecks Ererben fehlernder Attribute |
|||
in den jeweiligen technischen Elternklassenv werden die Attribute gesammelt und bei der Ausfuehrung komprimmiert. |
|||
Die so zusammen gesammelten Konfigurationen werden der jeweilgen Funktionsklasse uebergeben. |
|||
""" |
|||
import os |
|||
import basic.constants as B |
|||
import model.entity |
|||
import tools.path_const as P |
|||
import tools.data_tool |
|||
import tools.data_const as D |
|||
|
|||
TABLE_NAME = tools.data_tool.getSingularKeyword(B.DATA_NODE_TOPICS) |
|||
""" system-name for this entity """ |
|||
FIELD_ID = "toid" |
|||
FIELD_NAME = D.FIELD_NAME |
|||
LIST_FIELDS = [FIELD_ID, FIELD_NAME] |
|||
""" list of object-attributes """ |
|||
LIST_NODES = [] |
|||
LIST_SUBTABLES = {} |
|||
|
|||
component = "" |
|||
environment = "" |
|||
topic = "" # |
|||
""" one of B.LIST_TOPIC_NODES """ |
|||
type = "" # |
|||
""" one of the implemented Tools """ |
|||
|
|||
class Topic(model.entity.Entity): |
|||
name = "" |
|||
type = "" |
|||
attributes = "" |
|||
environment = "" |
|||
component = "" |
|||
|
|||
def __init__(self, job, environment, component, name=""): |
|||
""" |
|||
to be initialized by readSpec |
|||
""" |
|||
self.job = job |
|||
self.environment = environment |
|||
self.component = component |
|||
|
|||
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, "") |
|||
|
|||
def getFieldList(self): |
|||
return LIST_FIELDS |
|||
|
|||
def getNodeList(self): |
|||
return LIST_NODES |
|||
|
|||
def getSubtableList(self): |
|||
return LIST_SUBTABLES |
@ -0,0 +1,122 @@ |
|||
#!/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.testcase |
|||
import model.entity |
|||
import tools.data_tool |
|||
|
|||
HOME_PATH = test.constants.HOME_PATH |
|||
PYTHON_CMD = "python" |
|||
TEST_FUNCTIONS = ["test_10setAttributes"] |
|||
TEST_FUNCTIONS = ["test_10setAttributes"] |
|||
LIST_XARGS = ["lorem", "ipsum"] |
|||
PROGRAM_NAME = "clean_workspace" |
|||
|
|||
class MyTestCase(unittest.TestCase): |
|||
mymsg = "--------------------------------------------------------------" |
|||
|
|||
def test_10setAttributes(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() |
|||
tcname = "TC0001" |
|||
tcproject = "TESTPROJ" |
|||
testcase = model.testcase.Testcase(job, tcproject) |
|||
# eigene Attribute vollstaendig |
|||
testcase = model.testcase.Testcase(job, tcproject) |
|||
|
|||
args = {} |
|||
args[tcname] = {} |
|||
for k in model.testcase.LIST_FIELDS: |
|||
args[tcname][k] = "ATTR_" + k |
|||
testcase = testcase.setAttributes(job, args, tcname, |
|||
model.testcase.LIST_FIELDS, |
|||
model.testcase.LIST_NODES, |
|||
model.testcase.LIST_SUBTABLES) |
|||
for k in model.testcase.LIST_FIELDS: |
|||
if k == model.testcase.FIELD_NAME: |
|||
self.assertEqual(tcname, getattr(testcase, k)) |
|||
elif k == model.testcase.FIELD_PROJECT: |
|||
self.assertEqual(tcproject, getattr(testcase, k)) |
|||
else: |
|||
self.assertEqual(getattr(testcase, k), "ATTR_" + k) |
|||
for k in LIST_XARGS: |
|||
self.assertEqual(hasattr(testcase, k), False) |
|||
self.assertEqual(hasattr(testcase, tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS)), False) |
|||
# andere Attribute vollstaendig |
|||
testcase = model.testcase.Testcase(job, tcproject) |
|||
args = {} |
|||
args[tcname] = {} |
|||
attr = {} |
|||
for k in LIST_XARGS: |
|||
args[tcname][k] = "ATTR_" + k |
|||
attr[k] = "ATTR_" + k |
|||
args[tcname][B.NODE_ATTRIBUTES] = attr |
|||
topics = {} |
|||
for k in B.LIST_TOPIC_NODES: |
|||
topics[k] = {} |
|||
topics[k]["type"] = "x-type" |
|||
args[tcname][tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS)] = topics |
|||
testcase = testcase.setAttributes(job, args, tcname, |
|||
model.testcase.LIST_FIELDS, |
|||
model.testcase.LIST_NODES, |
|||
model.testcase.LIST_SUBTABLES) |
|||
for k in model.testcase.LIST_FIELDS: |
|||
if k == model.testcase.FIELD_NAME: |
|||
self.assertEqual(tcname, getattr(testcase, k)) |
|||
elif k == model.testcase.FIELD_PROJECT: |
|||
self.assertEqual(tcproject, getattr(testcase, k)) |
|||
else: |
|||
self.assertEqual("", getattr(testcase, k)) |
|||
for k in LIST_XARGS: |
|||
self.assertEqual(hasattr(testcase, k), False) |
|||
for k in model.testcase.LIST_NODES: |
|||
self.assertEqual(hasattr(testcase, k), True) |
|||
self.assertEqual(hasattr(testcase, tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS)), True) |
|||
for k in B.LIST_TOPIC_NODES: |
|||
self.assertEqual(hasattr(testcase, k), False) |
|||
self.assertIn(k ,testcase.topics) |
|||
|
|||
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() |
|||
testcase = model.testcase.Testcase(job, "TESTPROJ") |
|||
entityNames = [] |
|||
entityNames = testcase.get_entities(job, storage=model.entity.STORAGE_FILE) |
|||
self.assertEqual(type(entityNames), list) |
|||
#entityNames = testcase.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() |
|||
testcase = model.testcase.Testcase(job, "TESTPROJ") |
|||
name = "TC0001" |
|||
acttestcase = testcase.read_entity(job, name) |
|||
self.assertEqual(getattr(acttestcase, model.testcase.FIELD_NAME), name) |
|||
self.assertRaises(Exception, testcase.read_entity, job, "xyzxyz") |
|||
|
|||
if __name__ == '__main__': |
|||
unittest.main() |
Loading…
Reference in new issue