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.

85 lines
2.6 KiB

import unittest
import os
import inspect
import utils.path_tool
2 years ago
import basic.message
import basic.program
import basic.constants as B
import test.constants
import test.testtools
import utils.path_const as P
import basic.catalog
HOME_PATH = test.constants.HOME_PATH
OS_SYSTEM = test.constants.OS_SYSTEM
# here you can select single testfunction for developping the tests
2 years ago
TEST_FUNCTIONS = ["test_01class", "test_02read", "test_03key"]
#TEST_FUNCTIONS = [ "test_03key"]
2 years ago
verbose = False
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def test_01class(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
catalog = basic.catalog.Catalog.getInstance()
self.assertIsNotNone(catalog)
2 years ago
cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
2 years ago
def test_02read(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
2 years ago
catalog = basic.catalog.Catalog.getInstance()
self.assertRaises(Exception, catalog.readDomain, ("xxx", job))
cnttest += 1
res = catalog.readDomain("countries", job)
self.assertEqual(isinstance(res, dict), True)
cnttest += 1
countries = catalog.getKeys("countries", job)
self.assertEqual(len(countries), 21)
cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_03key(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
catalog = basic.catalog.Catalog.getInstance()
res = catalog.getValue("countries", "key", job)
self.assertEqual(res, "")
self.assertEqual(job.m.rc, basic.message.RC_ERROR)
cnttest += 1
res = catalog.getValue("countries", "TD", job)
print(str(res))
self.assertEqual(res["Land"], "Tschad")
print(str(res))
cnttest += 1
res = catalog.getValue("sender", "firma", job)
print(str(res))
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_zzz(self):
if verbose: print(MyTestCase.mymsg)
if __name__ == '__main__':
2 years ago
verbose = True
unittest.main()