Ulrich Carmesin
3 years ago
11 changed files with 281 additions and 156 deletions
@ -1 +1,2 @@ |
|||||
HOME_PATH = "/home/ulrich/6_Projekte/Programme/datest" |
HOME_PATH = "/home/ulrich/6_Projekte/Programme/datest" |
||||
|
OS_SYSTEM = "linux" |
@ -1,44 +1,156 @@ |
|||||
import unittest, os |
import unittest |
||||
|
import os |
||||
|
import inspect |
||||
import utils.path_tool |
import utils.path_tool |
||||
from basic.program import Job |
import basic.program |
||||
|
import basic.constants as B |
||||
import test.constants |
import test.constants |
||||
|
import test.testtools |
||||
|
import utils.path_const as P |
||||
|
|
||||
HOME_PATH = test.constants.HOME_PATH |
HOME_PATH = test.constants.HOME_PATH |
||||
|
OS_SYSTEM = test.constants.OS_SYSTEM |
||||
|
|
||||
|
# here you can select single testfunction for developping the tests |
||||
|
TEST_FUNCTIONS = ["test_key", "test_rejoinPath", "test_rejoinPath", "test_composePath", "test_composePattern", |
||||
|
"test_extractPath", "test_extractPattern"] |
||||
|
#TEST_FUNCTIONS = [ "test_extractPath"] |
||||
|
|
||||
class MyTestCase(unittest.TestCase): |
class MyTestCase(unittest.TestCase): |
||||
def runTest(self): |
mymsg = "--------------------------------------------------------------" |
||||
self.test_path() |
|
||||
|
|
||||
def test_key(self): |
def setTestPaths(self, job): |
||||
|
# here you can overwrite your workspace-configuration in order to get stable unittests |
||||
|
job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_HOME] = "home/unittest" |
||||
|
job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_TDATA] = "home/unittest/tdata" |
||||
|
job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ENV] = "home/unittest/env" |
||||
|
job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV] = "home/unittest/archiv" |
||||
pass |
pass |
||||
|
|
||||
def test_path(self): |
def setPathConfig(self, pt): |
||||
job = Job("unit") |
# here you can overwrite your workspace-configuration in order to get stable unittests |
||||
args = {"application": "TEST", "environment": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool", |
paths = pt.getInstance() |
||||
"modus": "unit", "testcase": "TESTFALL", "release": "V0.1", "tctime": "2021-08-21_12-02-01" } |
paths.pattern[P.P_ENVBASE] = "{job.conf.environment}/{job.par.environment}" |
||||
job.par.setParameterArgs(args) |
|
||||
|
|
||||
|
def test_key(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 = utils.path_tool.getKeyValue("job.par."+B.PAR_ENV, None) |
||||
|
self.assertEqual(res, test.testtools.DEFAULT_ENV) |
||||
|
cnttest += 1 |
||||
|
for par in [B.ATTR_PATH_TDATA, B.ATTR_PATH_ARCHIV, B.ATTR_PATH_ENV, B.ATTR_PATH_PROGRAM]: |
||||
|
res = utils.path_tool.getKeyValue("job.conf."+par, None) |
||||
|
self.assertIn(HOME_PATH, res) |
||||
|
cnttest += 1 |
||||
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
||||
|
|
||||
|
|
||||
|
def test_rejoinPath(self): |
||||
|
global mymsg |
||||
|
actfunction = str(inspect.currentframe().f_code.co_name) |
||||
|
cnttest = 0 |
||||
|
if actfunction not in TEST_FUNCTIONS: |
||||
|
return |
||||
|
if OS_SYSTEM == "linux": |
||||
|
res = utils.path_tool.rejoinPath("home", "ulrich") |
||||
|
self.assertEqual(res, "/home/ulrich") |
||||
|
cnttest += 1 |
||||
|
res = utils.path_tool.rejoinPath("opt") |
||||
|
self.assertEqual(res, "/opt") |
||||
|
cnttest += 1 |
||||
|
res = utils.path_tool.rejoinPath("http://domain.com", "application", "function") |
||||
|
self.assertEqual(res, "http://domain.com/application/function") |
||||
|
cnttest += 1 |
||||
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
||||
|
|
||||
|
|
||||
|
def test_composePath(self): |
||||
|
global mymsg |
||||
|
actfunction = str(inspect.currentframe().f_code.co_name) |
||||
|
cnttest = 0 |
||||
|
if actfunction not in TEST_FUNCTIONS: |
||||
|
return |
||||
|
# set the relevant datastrutures |
||||
|
job = test.testtools.getJob() |
||||
|
comp = test.testtools.getComp() |
||||
pt = utils.path_tool.PathConf() |
pt = utils.path_tool.PathConf() |
||||
r = utils.path_tool.getKeyValue("job.par.application") |
self.setTestPaths(job) |
||||
#print(r) |
self.setPathConfig(pt) |
||||
r = utils.path_tool.getKeyValue("job.conf.results") |
# tests |
||||
#print(r) |
path = utils.path_tool.composePath(P.P_ENVBASE, None) |
||||
self.assertEqual(r, os.path.join(HOME_PATH,"test","target")) |
self.assertIn(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ENV], path) |
||||
r = utils.path_tool.composePath("tcbase", None) |
self.assertIn(getattr(job.par, B.PAR_ENV), path) |
||||
#print(r) |
cnttest += 2 |
||||
args = { "application" : "TEST" , "application" : "ENV01", "modus" : "unit", "loglevel" : "debug", |
path = utils.path_tool.composePath(P.P_TCLOG, None) |
||||
"tool" : "job_tool", "tsdir": os.path.join(HOME_PATH, "test","conf","lauf","V0.1","startjob","2021-08-21_18-ß2-01")} |
self.assertIn(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV], path) |
||||
job = Job.resetInstance("unit") |
self.assertIn(getattr(job.par, B.PAR_TESTCASE), path) |
||||
job.par.setParameterArgs(args) |
cnttest += 2 |
||||
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
||||
|
|
||||
|
|
||||
|
def test_composePattern(self): |
||||
|
global mymsg |
||||
|
actfunction = str(inspect.currentframe().f_code.co_name) |
||||
|
cnttest = 0 |
||||
|
if actfunction not in TEST_FUNCTIONS: |
||||
|
return |
||||
|
# set the relevant datastrutures |
||||
|
job = test.testtools.getJob() |
||||
|
comp = test.testtools.getComp() |
||||
|
pt = utils.path_tool.PathConf() |
||||
|
self.setTestPaths(job) |
||||
|
self.setPathConfig(pt) |
||||
|
# tests |
||||
|
path = utils.path_tool.composePattern("{"+P.P_ENVBASE+"}", None) |
||||
|
self.assertIn(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ENV], path) |
||||
|
self.assertIn(getattr(job.par, B.PAR_ENV), path) |
||||
|
cnttest += 2 |
||||
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
||||
|
|
||||
|
|
||||
|
def test_extractPattern(self): |
||||
|
global mymsg |
||||
|
actfunction = str(inspect.currentframe().f_code.co_name) |
||||
|
cnttest = 0 |
||||
|
if actfunction not in TEST_FUNCTIONS: |
||||
|
return |
||||
|
job = test.testtools.getJob() |
||||
|
pt = utils.path_tool.PathConf() |
||||
|
job = test.testtools.getJob("ts", test.testtools.DEFAULT_APP, test.testtools.DEFAULT_ENV, "2021-08-21_18-ß2-01") |
||||
r = utils.path_tool.extractPattern("tsbase" ) |
r = utils.path_tool.extractPattern("tsbase" ) |
||||
#print(r) |
|
||||
self.assertEqual(r[0][1], "job.conf.archiv") |
self.assertEqual(r[0][1], "job.conf.archiv") |
||||
self.assertEqual(r[3][0], "_") |
self.assertEqual(r[1][1], P.KEY_TESTSUITE) |
||||
r = utils.path_tool.extractPath("tsbase" , os.path.join(HOME_PATH, "test","conf","lauf","V0.1","startjob_2021-08-21_10-02-01")) |
self.assertEqual(r[1][2], "testlauf") |
||||
#print("r " + str(r)) |
cnttest += 3 |
||||
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
||||
|
|
||||
|
|
||||
|
def test_extractPath(self): |
||||
|
global mymsg |
||||
|
actfunction = str(inspect.currentframe().f_code.co_name) |
||||
|
cnttest = 0 |
||||
|
if actfunction not in TEST_FUNCTIONS: |
||||
|
return |
||||
|
job = test.testtools.getJob() |
||||
|
pt = utils.path_tool.PathConf() |
||||
|
r = utils.path_tool.extractPath("tsbase" , os.path.join(HOME_PATH, "test","conf","lauf","testlauf","startjob_2021-08-21_10-02-01")) |
||||
|
print("r " + str(r)) |
||||
#print(vars(job.par)) |
#print(vars(job.par)) |
||||
self.assertEqual(job.par.release, "V0.1") |
#self.assertEqual(job.par.release, "V0.1") |
||||
self.assertEqual(job.par.usecase, "startjob") |
self.assertEqual(job.par.usecase, "startjob") |
||||
self.assertEqual(job.par.tltime, "2021-08-21_10-02-01") |
self.assertEqual(job.par.tstime, "2021-08-21_10-02-01") |
||||
|
cnttest += 2 |
||||
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
||||
|
|
||||
|
|
||||
|
def test_zzz(self): |
||||
|
print(MyTestCase.mymsg) |
||||
|
|
||||
|
|
||||
if __name__ == '__main__': |
if __name__ == '__main__': |
||||
unittest.main() |
unittest.main() |
||||
|
@ -1,44 +0,0 @@ |
|||||
# |
|
||||
pattern: |
|
||||
# Keywords |
|
||||
log: log |
|
||||
parfile: PARAMETER_{job.par.application}_{job.par.environment}.yml |
|
||||
precond: vorher |
|
||||
postcond: nachher |
|
||||
diff: diff_fach |
|
||||
prediff: diff_init |
|
||||
rundiff: diff_ablauf |
|
||||
result: Ergebnisse/{comp.name} |
|
||||
origin: original |
|
||||
parts: teilergebnisse |
|
||||
sumfile: xxx |
|
||||
backup: backup |
|
||||
reffile: Herkunft.txt |
|
||||
tc: testfall |
|
||||
ts: testlauf |
|
||||
debugname: debug |
|
||||
logname: log |
|
||||
debugs: "{job.conf.home}/test/log" |
|
||||
# environment |
|
||||
envbase: "{job.conf.environment}/{job.par.environment}" |
|
||||
envlog: "{envbase}/{log}" |
|
||||
envparfile: "{envbase}/{parfile}" |
|
||||
# testcase |
|
||||
tcbase: "{job.conf.archiv}/{job.par.testcase}/{job.par.tctime}" |
|
||||
tclog: "{tcbase}/{log}" |
|
||||
tcresult: "{tcbase}/{result}" |
|
||||
tcparfile: "{tcbase}/{parfile}" |
|
||||
tcdiff: "{tcresult}/{diff}" |
|
||||
tcprediff: "{tcresult}/{prediff}" |
|
||||
tcrundiff: "{tcresult}/{rundiff}" |
|
||||
tcprecond: "{tcresult}/{precond}" |
|
||||
tcpostcond: "{tcresult}/{postcond}" |
|
||||
# testset |
|
||||
tsbase: "{job.conf.archiv}/{ts}/{job.par.usecase}_{job.par.tstime}" |
|
||||
tslog: "{tsbase}/{log}" |
|
||||
tsparfile: "{tsbase}/{parfile}" |
|
||||
tssum: "{tsbase}/Ergebnis" |
|
||||
# expectation-result rs |
|
||||
xpbase: "{job.conf.expect}/{job.par.branch}" |
|
||||
xpresult: "{xpbase}/{result}" |
|
||||
xpbackup: "{xpbase}/{result}" |
|
@ -1,35 +0,0 @@ |
|||||
# |
|
||||
pattern: |
|
||||
# Keywords |
|
||||
log: Protokolle |
|
||||
parfile: PARAMETER_{job.par.application}_{job.par.environ}.yml |
|
||||
precond: vorher |
|
||||
postcond: nachher |
|
||||
diff: diff_fach |
|
||||
prediff: diff_init |
|
||||
rundiff: diff_ablauf |
|
||||
result: Ergebnisse/{comp.name} |
|
||||
origin: original |
|
||||
parts: teilergebnisse |
|
||||
sumfile: |
|
||||
backup: backup |
|
||||
reffile: Herkunft.txt |
|
||||
tc: testfall |
|
||||
ts: testlauf |
|
||||
# testcase |
|
||||
tcbase: {job.conf.archiv}/{job.par.release}/{job.par.testcase}/{job.par.tctime} |
|
||||
tcresult: {tcbase}/{result} |
|
||||
tcparfile: {tcbase}/{parfile} |
|
||||
tcdiff: {tcresult}/{diff} |
|
||||
tcprediff: {tcresult}/{prediff} |
|
||||
tcrundiff: {tcresult}/{rundiff} |
|
||||
precond: {tcresult}/vorher |
|
||||
postcond: {tcresult}/nachher |
|
||||
# testset |
|
||||
tsbase: {job.conf.archiv}/{job.par.release}/{job.par.usecase}_{job.par.tltime} |
|
||||
tsparfile: {tsbase}/{parfile} |
|
||||
tssum: {tsbase}/Ergebnis |
|
||||
# target-result rs |
|
||||
rsbase: {job.conf.results}/{job.par.branch} |
|
||||
rsresult: {rsbase}/{result} |
|
||||
rsbackup: {rsbase}/{result} |
|
Loading…
Reference in new issue