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.
 
 
 

105 lines
3.9 KiB

import json
import inspect
import unittest
import datetime
import utils.date_tool
TEST_FUNCTIONS = ["test_dateformat", "test_parseFormula", "test_parseDate"]
TEST_FUNCTIONS = ["test_parseDate"]
verbose = True
# class MyTestCase(unittest.TestCase):
class MyTestCase(unittest.TestCase):
TEST_FUNCTIONS = ["test_dateformat", "test_parseFormula", "test_parseDate"]
mymsg = "--------------------------------------------------------------"
"""
def runTest(self):
# -> Optional[unittest.result.TestResult]:
suite = unittest.TestSuite()
#suite.addTest(MyTestCase("test_dateformat"))
for t in TEST_FUNCTIONS:
suite.addTest(MyTestCase(t))
unittest.TextTestRunner().run(suite)
#suite = unittest.defaultTestLoader.loadTestsFromTestCase("MyTestCase")
if verbose: print("run own test " + str(suite))
"""
def test_dateformat(self, result=None):
if verbose: print(str(result))
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if verbose: print("test_dateformat -------")
if actfunction not in TEST_FUNCTIONS:
return
stime = datetime.datetime.now()
if verbose: print(stime)
tdate = (2022, 2, 10)
sdate = datetime.datetime(tdate[0], tdate[1],tdate[2], 3, 32, 23)
#sdate = datetime.datetime(stime)
if verbose: print(sdate)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_parseFormula(self, result=None):
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
res = utils.date_tool.parseFormula("{(21.12.2012 +1Y)}")
if verbose: print(str(res))
self.assertEqual(res[0], 2013)
self.assertEqual(res[3], 0)
res = utils.date_tool.parseFormula("{(21.12.2012 +1Y -1M)}")
if verbose: print(str(res))
self.assertEqual(res[0], 2013)
self.assertEqual(res[1], 11)
self.assertEqual(res[3], 0)
res = utils.date_tool.parseFormula("{(21.12.2012 +1 Jahre +20 Tage)}")
if verbose: print(str(res))
self.assertEqual(res[0], 2014)
self.assertEqual(res[1], 1)
self.assertEqual(res[2], 10)
self.assertEqual(res[3], 0)
res = utils.date_tool.parseFormula("{(21.12.2012_11:12:43 +1Y)}")
if verbose: print(str(res))
self.assertEqual(res[0], 2013)
self.assertEqual(res[5], 43)
res = utils.date_tool.parseFormula("{(21.12.2012 -60M)}")
if verbose: print(str(res))
self.assertEqual(res[0], 2007)
self.assertEqual(res[1], 12)
self.assertEqual(res[3], 0)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_parseDate(self, result=None):
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
res = utils.date_tool.parseDate("21.12.2012")
if verbose: print(str(res))
self.assertEqual(res[0], 2012)
self.assertEqual(res[3], 0)
res = utils.date_tool.parseDate("{(21.12.2012 +1Y)}")
if verbose: print(str(res))
self.assertEqual(res[0], 2013)
self.assertEqual(res[3], 0)
res = utils.date_tool.parseDate("Wed May 18 23:32:55 2022 +0200")
if verbose: print(str(res))
self.assertEqual(res[0], 2022)
self.assertEqual(res[1], 5)
res = utils.date_tool.parseDate("Mit Dez 18 23:32:55 2021 +0200")
if verbose: print(str(res))
self.assertEqual(res[0], 2021)
self.assertEqual(res[1], 12)
res = utils.date_tool.parseDate("Sun Sep 4 15:12:21 2022 +0200")
if verbose: print(str(res))
self.assertEqual(res[0], 2022)
self.assertEqual(res[1], 9)
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
if __name__ == '__main__':
unittest.main()