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.
 
 
 

132 lines
5.2 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.variant
import model.entity
import tools.data_const as D
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)
entityNames = []
entityNames = variant.read_unique_names(job, "", "", "", {})
self.assertEqual(type(entityNames), list)
#entityNames = variant.select_unique_names(job, "", "", "", {})
#self.assertEqual(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)
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)
name = "xml-rest"
actrelease = variant.read_entity(job, name)
self.assertEqual(getattr(actrelease, D.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)
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.assertEqual(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)
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.assertEqual(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()