Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.6 KiB

#!/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
import tools.data_const as D
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, tcname)
# eigene Attribute vollstaendig
testcase = model.testcase.Testcase(job, tcname)
args = {}
args[tcname] = {}
for k in model.testcase.Testcase.LIST_FIELDS:
args[tcname][k] = "ATTR_" + k
testcase = testcase.setAttributes(job, args, tcname,
model.testcase.Testcase.LIST_FIELDS,
model.testcase.Testcase.LIST_NODES,
model.testcase.Testcase.LIST_SUBTABLES)
for k in model.testcase.Testcase.LIST_FIELDS:
if k == D.FIELD_NAME:
self.assertEqual(tcname, getattr(testcase, 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, tcname)
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.Testcase.LIST_FIELDS,
model.testcase.Testcase.LIST_NODES,
model.testcase.Testcase.LIST_SUBTABLES)
for k in model.testcase.Testcase.LIST_FIELDS:
if k == D.FIELD_NAME:
self.assertEqual(tcname, getattr(testcase, k))
for k in LIST_XARGS:
self.assertEqual(hasattr(testcase, k), False)
for k in model.testcase.Testcase.LIST_NODES:
1 year ago
print(k)
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)
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)
name = "TC0001"
acttestcase = testcase.read_entity(job, name)
self.assertEqual(getattr(acttestcase, D.FIELD_NAME), name)
self.assertRaises(Exception, testcase.read_entity, job, "xyzxyz")
if __name__ == '__main__':
unittest.main()