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.
 
 
 

94 lines
3.1 KiB

#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import unittest
import inspect
import basic.message
import basic.program
import test.constants
import test.testtools
import objects.catalog
HOME_PATH = test.constants.HOME_PATH
OS_SYSTEM = test.constants.OS_SYSTEM
# here you can select single testfunction for developping the tests
TEST_FUNCTIONS = ["test_01class", "test_02read", "test_03key"]
# TEST_FUNCTIONS = [ "test_02read"]
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 = objects.catalog.Catalog.getInstance()
self.assertIsNotNone(catalog)
cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
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()
catalog = objects.catalog.Catalog.getInstance()
self.assertRaises(Exception, catalog.readDomain, ("xxx", job))
cnttest += 1
try:
res = catalog.readDomain("countries", job)
self.assertEqual(isinstance(res, dict), True)
res = catalog.readDomain("programs", job)
self.assertEqual(isinstance(res, dict), True)
except:
print ("except")
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 = objects.catalog.Catalog.getInstance()
res = catalog.getValue(job, "countries", "key", "")
self.assertEqual(res, "")
self.assertEqual(job.m.rc, basic.message.RC_ERROR)
cnttest += 1
res = catalog.getValue(job, "countries", "TD", "")
print(str(res))
self.assertEqual(res["Land"], "Tschad")
cnttest += 1
res = catalog.getValue(job, "countries", "TD", "Land")
print(str(res))
self.assertEqual(res, "Tschad")
cnttest += 1
res = catalog.getValue(job, "sender", "firma", "")
print(str(res))
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_zzz(self):
if verbose: print(MyTestCase.mymsg)
if __name__ == '__main__':
verbose = True
unittest.main()