Ulrich Carmesin
3 years ago
2 changed files with 147 additions and 0 deletions
@ -1,17 +1,76 @@ |
|||||
import json |
import json |
||||
|
import inspect |
||||
import unittest |
import unittest |
||||
import datetime |
import datetime |
||||
import utils.date_tool |
import utils.date_tool |
||||
|
|
||||
|
#TEST_FUNCTIONS = ["test_dateformat", "test_parseFormula", "test_parseDate"] |
||||
|
TEST_FUNCTIONS = ["test_parseFormula"] |
||||
|
|
||||
class MyTestCase(unittest.TestCase): |
class MyTestCase(unittest.TestCase): |
||||
|
mymsg = "--------------------------------------------------------------" |
||||
|
|
||||
|
|
||||
def test_dateformat(self): |
def test_dateformat(self): |
||||
|
actfunction = str(inspect.currentframe().f_code.co_name) |
||||
|
cnttest = 0 |
||||
|
if actfunction not in TEST_FUNCTIONS: |
||||
|
return |
||||
stime = datetime.datetime.now() |
stime = datetime.datetime.now() |
||||
print(stime) |
print(stime) |
||||
tdate = (2022, 2, 10) |
tdate = (2022, 2, 10) |
||||
sdate = datetime.datetime(tdate[0], tdate[1],tdate[2], 3, 32, 23) |
sdate = datetime.datetime(tdate[0], tdate[1],tdate[2], 3, 32, 23) |
||||
sdate = datetime.datetime(stime) |
sdate = datetime.datetime(stime) |
||||
print(sdate) |
print(sdate) |
||||
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
||||
|
|
||||
|
|
||||
|
def test_parseFormula(self): |
||||
|
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)}") |
||||
|
print(str(res)) |
||||
|
self.assertEqual(res[0], 2013) |
||||
|
self.assertEqual(res[3], 0) |
||||
|
res = utils.date_tool.parseFormula("{(21.12.2012 +1Y -1M)}") |
||||
|
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)}") |
||||
|
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)}") |
||||
|
print(str(res)) |
||||
|
self.assertEqual(res[0], 2013) |
||||
|
self.assertEqual(res[5], 43) |
||||
|
res = utils.date_tool.parseFormula("{(21.12.2012 -60M)}") |
||||
|
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): |
||||
|
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") |
||||
|
print(str(res)) |
||||
|
self.assertEqual(res[0], 2012) |
||||
|
self.assertEqual(res[3], 0) |
||||
|
res = utils.date_tool.parseDate("{(21.12.2012 +1Y)}") |
||||
|
print(str(res)) |
||||
|
self.assertEqual(res[0], 2012) |
||||
|
self.assertEqual(res[3], 0) |
||||
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
||||
|
|
||||
if __name__ == '__main__': |
if __name__ == '__main__': |
||||
unittest.main() |
unittest.main() |
||||
|
Loading…
Reference in new issue