Browse Source

test constants

master
Ulrich Carmesin 3 years ago
parent
commit
018d719071
  1. 34
      test/conf/basis.yml
  2. 2
      test/constants.py
  3. 16
      test/test_file.py
  4. 10
      test/test_job.py
  5. 8
      test/test_main.py
  6. 5
      test/test_path.py

34
test/conf/basis.yml

@ -1,34 +0,0 @@
tools:
connsrc: yml
remotetyp: ssh
toolcls:
pathTool: path_tool
paths:
mode: "0o775"
home: /home/ulrich/6_Projekte/Programme/pythonProject
debugs: /home/ulrich/6_Projekte/Programme/pythonProject/test/log # for temporary debug-logs
archiv: /home/ulrich/6_Projekte/Programme/pythonProject/test/lauf # the results of
results: /home/ulrich/6_Projekte/Programme/pythonProject/test/target # the target results which a former result files
program: /home/ulrich/6_Projekte/Programme/pythonProject # the programs with default configs
environment: /home/ulrich/6_Projekte/Programme/pythonProject/test/environment # for config etc about the system under test
release: /home/ulrich/6_Projekte/Programme/pythonProject/test/release # for configs about special releases
testdata: /home/ulrich/6_Projekte/Programme/pythonProject/test/tdata # for configs about special releases
pattern:
tctime: '\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}'
tltime: '\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}'
testcase: '.*?/'
usecase: '.*?/'
typen:
einzel: "Einzelfaelle separat"
menge: "alle zum Lauf einmal laden und auswerten"
unit:
text: "Units testen"
todo: 1
applicationen:
TEST:
- testA
- testB
application:
TEST:
- testA
- testB

2
test/constants.py

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

16
test/test_file.py

@ -1,11 +1,13 @@
import unittest import unittest, os
import utils.file_tool as t import utils.file_tool as t
import utils.path_tool import utils.path_tool
import basic.program import basic.program
import test.constants
HOME_PATH = test.constants.HOME_PATH
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
def xtest_getFiles(self): def test_getFiles(self):
job = basic.program.Job("unit") job = basic.program.Job("unit")
args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool", args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool",
"modus": "unit"} "modus": "unit"}
@ -19,21 +21,21 @@ class MyTestCase(unittest.TestCase):
r = t.getFilesRec(job.m, job.conf.confs.get("paths").get("program"), ".*?file.*.py") r = t.getFilesRec(job.m, job.conf.confs.get("paths").get("program"), ".*?file.*.py")
print (r) print (r)
def xtest_pathTool(self): def test_pathTool(self):
job = basic.program.Job("unit") job = basic.program.Job("unit")
args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool", args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool",
"modus": "unit"} "modus": "unit"}
job.par.setParameterArgs(args) job.par.setParameterArgs(args)
#self.assertEqual(utils.path_tool.generatePath("program", "komp", "testA", "CONFIG.yml"), #self.assertEqual(utils.path_tool.generatePath("program", "komp", "testA", "CONFIG.yml"),
# "/home/basic/6_Projekte/PythonProject/komponents/testA/COFIG.yml") # os.path.join(HOME_PATH, "components","testA","COFIG.yml"))
def test_encoding(self): def test_encoding(self):
print("------- test_encoding") print("------- test_encoding")
encodings = ['utf-8', 'windows-1250', 'iso-8859-1'] encodings = ['utf-8', 'windows-1250', 'iso-8859-1']
res = utils.file_tool.getFileEncoding("/home/ulrich/6_Projekte/Programme/holtz/test/tdata/encoded_iso8859.txt") res = utils.file_tool.getFileEncoding(os.path.join(HOME_PATH,"test","tdata","encoded_iso8859.txt"))
self.assertEqual(res, "iso-8859-1") self.assertEqual(res, "iso-8859-1")
res = utils.file_tool.getFileEncoding("/home/ulrich/6_Projekte/Programme/holtz/test/tdata/encoded_win1250.txt") res = utils.file_tool.getFileEncoding(os.path.join(HOME_PATH,"test","tdata","encoded_win1250.txt"))
self.assertEqual(res, "iso-8859-1") self.assertEqual(res, "iso-8859-1")
res = utils.file_tool.getFileEncoding("/home/ulrich/6_Projekte/Programme/holtz/test/tdata/encoded_utf8.txt") res = utils.file_tool.getFileEncoding(os.path.join(HOME_PATH,"test","tdata","encoded_utf8.txt"))
self.assertEqual(res, "utf-8") self.assertEqual(res, "utf-8")

10
test/test_job.py

@ -30,17 +30,17 @@ class MyTestCase(unittest.TestCase):
cm.createComponents("testa", 1, "") cm.createComponents("testa", 1, "")
def test_run(self): def test_run(self):
# os.system("python /home/ulrich/6_Projekte/Programme/holtz/check_environment.py -a TEST -e ENV01") # os.system("python "+os.path.join(HOME_PATH, "check_environment.py")+" -a TEST -e ENV01")
# os.system("python /home/basic/6_Projekte/Programme/pythonProject/init_testset.py -a TEST -e ENV01 " # os.system("python "+os.path.join(HOME_PATH, "init_testset.py")+" -a TEST -e ENV01 "
# "-ts /home/basic/6_Projekte/Programme/holtz/test/lauf/V0.1/implement_2021-08-28_23-50-51 -dt csv -ds implement -dn firstunit") # "-ts "+os.path.join(HOME_PATH, "test","lauf","V0.1","implement_2021-08-28_23-50-51")+" -dt csv -ds implement -dn firstunit")
#os.system(PYTHON_CMD+" "+os.path.join(HOME_PATH,"init_testcase.py")+" -a TEST -e ENV01 " #os.system(PYTHON_CMD+" "+os.path.join(HOME_PATH,"init_testcase.py")+" -a TEST -e ENV01 "
# "-tc "+os.path.join(HOME_PATH,"test","lauf","V0.1","TC0001","2021-08-28_23-50-51")+" -dt csv -ds implement -dn TC0001") # "-tc "+os.path.join(HOME_PATH,"test","lauf","V0.1","TC0001","2021-08-28_23-50-51")+" -dt csv -ds implement -dn TC0001")
job = Job("unit") job = Job("unit")
args = { "application" : "TEST" , "environment" : "ENV01", "modus" : "unit", "loglevel" : "debug", args = { "application": "TEST", "environment": "ENV01", "modus": "unit", "loglevel": "debug", "tdtyp": "dir",
"tdsrc": "TC0001", "tdname": "xxx",
"tool": "job_tool", "tcdir": os.path.join(HOME_PATH,"test","lauf","V0.1","TC0001","2021-08-28_23-50-51")} "tool": "job_tool", "tcdir": os.path.join(HOME_PATH,"test","lauf","V0.1","TC0001","2021-08-28_23-50-51")}
job.par.setParameterArgs(args) job.par.setParameterArgs(args)
job.setProgram("init_testcase") job.setProgram("init_testcase")
# os.system("python /home/basic/6_Projekte/Programme/pythonProject/init_testset.py")
init_testcase.start(job) init_testcase.start(job)
job.stopJob(1) job.stopJob(1)

8
test/test_main.py

@ -1,11 +1,15 @@
import unittest import unittest, os
import utils.path_tool as path_tool import utils.path_tool as path_tool
import basic.program as program import basic.program as program
import test.constants
HOME_PATH = test.constants.HOME_PATH
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
def test_pathTool(self): def test_pathTool(self):
x = program.Job("test:application=TEST:application=ENV01") x = program.Job("test:application=TEST:application=ENV01")
self.assertEqual(path_tool.generatePath("program", "komp", "testA", "CONFIG.yml"), "/home/ulrich/6_Projekte/holtz/components/testA/CONFIG.yml") self.assertEqual(path_tool.generatePath("program", "komp", "testA", "CONFIG.yml"),
os.path.join(HOME_PATH, "components","testA","CONFIG.yml"))
if __name__ == '__main__': if __name__ == '__main__':

5
test/test_path.py

@ -8,7 +8,6 @@ HOME_PATH = test.constants.HOME_PATH
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
def test_path(self): def test_path(self):
job = Job("unit") job = Job("unit")
#t = utils.path_tool.PathTool()
args = {"application": "TEST", "environment": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool", 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" } "modus": "unit", "testcase": "TESTFALL", "release": "V0.1", "tctime": "2021-08-21_12-02-01" }
job.par.setParameterArgs(args) job.par.setParameterArgs(args)
@ -17,15 +16,13 @@ class MyTestCase(unittest.TestCase):
print(r) print(r)
r = utils.path_tool.getKeyValue("job.conf.results") r = utils.path_tool.getKeyValue("job.conf.results")
print(r) print(r)
self.assertEqual(r, "/home/ulrich/6_Projekte/Programme/holtz/test/target") self.assertEqual(r, os.path.join(HOME_PATH,"test","target"))
r = utils.path_tool.composePath("tcbase", None) 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) print(r)
args = { "application" : "TEST" , "application" : "ENV01", "modus" : "unit", "loglevel" : "debug", args = { "application" : "TEST" , "application" : "ENV01", "modus" : "unit", "loglevel" : "debug",
"tool" : "job_tool", "tsdir": os.path.join(HOME_PATH, "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 = Job.resetInstance("unit")
job.par.setParameterArgs(args) 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 = utils.path_tool.extractPattern("tsbase" ) r = utils.path_tool.extractPattern("tsbase" )
print(r) print(r)
self.assertEqual(r[0][1], "job.conf.archiv") self.assertEqual(r[0][1], "job.conf.archiv")

Loading…
Cancel
Save