Ulrich
2 years ago
10 changed files with 216 additions and 112 deletions
|
@ -0,0 +1,69 @@ |
|||
import unittest |
|||
import os |
|||
import inspect |
|||
import tools.value_tool |
|||
import basic.program |
|||
import basic.constants as B |
|||
import test.constants |
|||
import test.testtools |
|||
|
|||
HOME_PATH = test.constants.HOME_PATH |
|||
DATA_PATH = test.constants.DATA_PATH |
|||
OS_SYSTEM = test.constants.OS_SYSTEM |
|||
|
|||
# here you can select single testfunction for developping the tests |
|||
TEST_FUNCTIONS = ["test_01key", "test_10pattern"] |
|||
TEST_FUNCTIONS = ["test_10pattern"] |
|||
verbose = True |
|||
job = None |
|||
|
|||
|
|||
class MyTestCase(unittest.TestCase): |
|||
mymsg = "--------------------------------------------------------------" |
|||
|
|||
def test_01key(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 = tools.value_tool.get_key_value(job, "job.par." + B.PAR_ENV, None) |
|||
self.assertEqual(res, test.testtools.DEFAULT_ENV) |
|||
cnttest += 1 |
|||
for p in [B.ATTR_PATH_ARCHIV, B.ATTR_PATH_ENV]: |
|||
res = tools.value_tool.get_key_value(job, "job.conf." + p, None) |
|||
if verbose: print("assertIn "+p+": "+res+" -- "+HOME_PATH) |
|||
self.assertIn(HOME_PATH, res) |
|||
cnttest += 1 |
|||
res = tools.value_tool.get_key_value(job, "job.program", None) |
|||
self.assertIn("unit_tester", res) |
|||
res = tools.value_tool.get_key_value(job, "ctlg.programs.unit_tester.dirname", None) |
|||
self.assertIn("wsdir", res) |
|||
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
|||
|
|||
def test_10pattern(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 = tools.value_tool.compose_pattern(job, "wsdir", None) |
|||
self.assertEqual(res, os.path.join(B.HOME_PATH, "workspace")) |
|||
cnttest += 1 |
|||
setattr(job.par, "wsdir", res) |
|||
res = tools.value_tool.compose_string(job, "{job.par.wsdir}/{log}/{job.program}_{job.start}.txt", None) |
|||
regex = os.path.join(B.HOME_PATH, "workspace", "log", "unit_tester_\d{8}_\d{6}.txt") |
|||
self.assertRegex(res, regex) |
|||
cnttest += 1 |
|||
# "{job.par.wsdir}/{log}/{job.program}_{job.start}.txt" |
|||
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
|||
|
|||
def test_zzz(self): |
|||
if verbose: print(MyTestCase.mymsg) |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
unittest.main() |
|||
job.stopJob() |
Loading…
Reference in new issue