diff --git a/test/constants.py b/test/constants.py index b3ced8a..db175ed 100644 --- a/test/constants.py +++ b/test/constants.py @@ -1,4 +1,17 @@ -HOME_PATH = "/home/ulrich/6_Projekte/Programme/datest" -DATA_PATH = "/home/ulrich/6_Projekte/Programme/data" -COMP_PATH = "/home/ulrich/6_Projekte/Programme/data/components" +""" +constants +""" +import os +home = os.getcwd() +prgdir = "" +if home[-6:] == "datest": + prgdir = home[-6:] + home = home[0:-7] +elif home[-7:] == "program": + prgdir = home[-7:] + home = home[0:-8] +HOME_PATH = home +DATA_PATH = os.path.join(home, "data") +PROG_PATH = os.path.join(home, prgdir) +COMP_PATH = os.path.join(home, prgdir, "components") OS_SYSTEM = "linux" \ No newline at end of file diff --git a/test/test_date.py b/test/test_01date.py similarity index 60% rename from test/test_date.py rename to test/test_01date.py index 17c6acb..80acf06 100644 --- a/test/test_date.py +++ b/test/test_01date.py @@ -3,72 +3,90 @@ import inspect import unittest import datetime import utils.date_tool +import test.abstractTestcase -#TEST_FUNCTIONS = ["test_dateformat", "test_parseFormula", "test_parseDate"] -TEST_FUNCTIONS = ["test_parseFormula"] +TEST_FUNCTIONS = ["test_dateformat", "test_parseFormula", "test_parseDate"] +#TEST_FUNCTIONS = ["test_parseFormula"] +verbose = True -class MyTestCase(unittest.TestCase): + +# class MyTestCase(unittest.TestCase): +class MyTestCase(test.abstractTestcase.MyTestCase): + 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): + 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() - print(stime) + if verbose: print(stime) tdate = (2022, 2, 10) sdate = datetime.datetime(tdate[0], tdate[1],tdate[2], 3, 32, 23) - sdate = datetime.datetime(stime) - print(sdate) + #sdate = datetime.datetime(stime) + if verbose: print(sdate) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) - def test_parseFormula(self): + 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)}") - print(str(res)) + 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)}") - print(str(res)) + 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)}") - print(str(res)) + 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)}") - print(str(res)) + if verbose: 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)) + 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): + 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") - print(str(res)) + if verbose: 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) + if verbose: print(str(res)) + self.assertEqual(res[0], 2013) self.assertEqual(res[3], 0) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) diff --git a/test/test_css.py b/test/test_02css.py similarity index 77% rename from test/test_css.py rename to test/test_02css.py index 258bb8f..187c341 100644 --- a/test/test_css.py +++ b/test/test_02css.py @@ -1,20 +1,30 @@ +""" +unit-test +""" import unittest import utils.css_tool import basic.program import json +# 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_01css"] +#TEST_FUNCTIONS = ["test_01css"] +# with this variable you can switch prints on and off +verbose = False + class MyTestCase(unittest.TestCase): def runTest(self): self.test_css() - def test_css(self): + def test_01css(self): job = basic.program.Job("unit") - args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", + args = {"application": "TEST", "environment": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool", "tdtyp": "csv", "tdsrc": "implement", "tdname": "firstunit", "modus": "unit"} job.par.setParameterArgs(args) - print("eeeeeeeee") - print(json.dumps(job.conf.confs)) + if verbose: print("eeeeeeeee") + if verbose: print(json.dumps(job.conf.confs)) # ------- inline --------------- job.conf.setConfig("tools.csstyp", "inline") job.conf.confs.get("tools")["csstyp"] == "inline" @@ -40,38 +50,39 @@ class MyTestCase(unittest.TestCase): self.assertEqual(len(text), 15) self.assertEqual(("class" in text), True) text = utils.css_tool.getInternalStyle("diffFiles") - print(text) + if verbose: print(text) self.assertEqual(len(text), 262) self.assertEqual(("