Browse Source

tests with constants

master
Ulrich Carmesin 3 years ago
parent
commit
33d90d6b4a
  1. 1
      test/constants.py
  2. 12
      test/test_config.py
  3. 3
      test/test_job.py
  4. 22
      test/test_path.py

1
test/constants.py

@ -0,0 +1 @@
HOME_PATH = "/home/ulrich/6_Projekte/Programme/holtz"

12
test/test_config.py

@ -1,7 +1,10 @@
import unittest
import utils.config_tool as t
from basic.program import Job
import test.constants
import os
HOME_PATH = test.constants.HOME_PATH
class MyTestCase(unittest.TestCase):
def test_something(self):
@ -10,16 +13,11 @@ class MyTestCase(unittest.TestCase):
"modus": "unit"}
job.par.setParameterArgs(args)
r = t.getConfigPath("tool", "path")
print (r)
self.assertEqual(r, "/home/basic/6_Projekte/Programme/pythonProject/utils/configs/path.yml")
r = t.getConfigPath("comp", "TestA2")
print (r)
self.assertEqual(r, os.path.join(HOME_PATH, "utils","configs","path.yml"))
r = t.getConfigPath("comp", "TestX2")
self.assertEqual(r, None)
r = t.getConfigPath("comp", "testA2")
print (r)
r = t.getConfig("tool", "path")
print (r)
#r = t.getConfig("comp", "testA2")
print("pattern " + r["pattern"]["log"])
print("pattern " + r["pattern"]["precond"])

3
test/test_job.py

@ -3,8 +3,9 @@ import os
from basic.program import Job
from basic.componentHandling import ComponentManager
import init_testcase
import test.constants
HOME_PATH = "/home/ulrich/6_Projekte/Programme/holtz"
HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python"
class MyTestCase(unittest.TestCase):
def xtest_parameter(self):

22
test/test_path.py

@ -1,34 +1,36 @@
import unittest
import unittest, os
import utils.path_tool
from basic.program import Job
import test.constants
HOME_PATH = test.constants.HOME_PATH
class MyTestCase(unittest.TestCase):
def test_path(self):
job = Job("unit")
t = utils.path_tool.PathTool()
#t = utils.path_tool.PathTool()
args = {"application": "TEST", "environment": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool",
"modus": "unit", "testcase": "TESTFALL", "release": "V0.1", "tctime": "2021-08-21_12-02-01" }
job.par.setParameterArgs(args)
pt = t.PathConf()
r = t.getKeyValue("job.par.application")
pt = utils.path_tool.PathConf()
r = utils.path_tool.getKeyValue("job.par.application")
print(r)
r = t.getKeyValue("job.conf.results")
r = utils.path_tool.getKeyValue("job.conf.results")
print(r)
self.assertEqual(r, "/home/basic/6_Projekte/Programme/pythonProject/test/target")
r = t.composePath("tcbase", None)
self.assertEqual(r, "/home/ulrich/6_Projekte/Programme/holtz/test/target")
r = utils.path_tool.composePath("tcbase", None)
#r = t.replaceNoPython("{job.conf.archiv}/{job.par.release}/{job.par.testcase}/{job.par.tctime}", "{job.conf.archiv}", "/home/basic/6_Projekte/Programme/pythonProject/test/lauf")
print(r)
args = { "application" : "TEST" , "application" : "ENV01", "modus" : "unit", "loglevel" : "debug",
"tool" : "job_tool", "tsdir": "/home/basic/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob/2021-08-21_18-ß2-01"}
"tool" : "job_tool", "tsdir": os.path.join(HOME_PATH, "test","lauf","V0.1","startjob","2021-08-21_18-ß2-01")}
job = Job.resetInstance("unit")
job.par.setParameterArgs(args)
# r = t.extractPath("tsbase" , "/home/basic/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob/2021-08-21_18-ß2-01")
r = t.extractPattern("tsbase" )
r = utils.path_tool.extractPattern("tsbase" )
print(r)
self.assertEqual(r[0][1], "job.conf.archiv")
self.assertEqual(r[3][0], "_")
r = t.extractPath("tsbase" , "/home/basic/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob_2021-08-21_10-02-01")
r = utils.path_tool.extractPath("tsbase" , os.path.join(HOME_PATH, "test","lauf","V0.1","startjob_2021-08-21_10-02-01"))
print("r " + str(r))
print(vars(job.par))
self.assertEqual(job.par.release, "V0.1")

Loading…
Cancel
Save