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.

108 lines
3.4 KiB

2 years ago
"""
unit-test
"""
import unittest
import inspect
import utils.gen_tool
import utils.gen_const as G
import basic.program
import test.testtools
# the list of TEST_FUNCTIONS defines which function will be really tested.
# if you minimize the list you can check the specific test-function
TEST_FUNCTIONS = ["test_11getValueList", "test_12getCntElement", "test_13getMinCount", "test_14getElemList"]
TEST_FUNCTIONS = ["test_01getElemList"]
# with this variable you can switch prints on and off
verbose = False
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def test_01getElemList(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
res = utils.gen_tool.getElemList(G.KEY_LIST, "0 .. 5", 6, job)
print((str(res)))
res = utils.gen_tool.getElemList(G.KEY_LIST, "a, b, c, d", 6, job)
print((str(res)))
res = utils.gen_tool.getElemList(G.KEY_LIST, "cat:countries", 6, job)
print((str(res)))
for cnt in [3, 15, 75, 400]:
res = utils.gen_tool.getElemList(G.KEY_LIST, "A, B,C , D", cnt, job)
self.assertEqual(len(res), cnt)
cnttest += 1
for cnt in [3, 15, 75, 400]:
res = utils.gen_tool.getElemList(G.KEY_LIST, "cat:countries", cnt, job)
self.assertEqual(len(res), cnt)
cnttest += 1
for cnt in [3, 15, 75, 400]:
res = utils.gen_tool.getElemList(G.KEY_LIST, "0 .. 4", cnt, job)
self.assertEqual(len(res), cnt)
cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
2 years ago
def test_11getValueList(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
for cnt in [3, 4, 6, 10]:
res = utils.gen_tool.getValueList(["A", "B", "C", "D"], cnt, job)
self.assertEqual(len(res), cnt)
cnttest += 1
for cnt in [3, 4, 6, 10]:
res = utils.gen_tool.getValueList("[A, B, C, D]", cnt, job)
self.assertEqual(len(res), cnt)
cnttest += 1
for cnt in [3, 4, 6, 10]:
res = utils.gen_tool.getValueList("0 .. 4", cnt, job)
self.assertEqual(len(res), cnt)
cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_12getCntElement(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
def test_13getMinCount(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
def test_14getElemList(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
def test_zzz(self):
if verbose: print(MyTestCase.mymsg)
if __name__ == '__main__':
verbose = True
unittest.main()