Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.6 KiB

import unittest
import os
import inspect
3 years ago
import utils.file_tool as t
import utils.path_tool
3 years ago
import basic.program
3 years ago
import test.constants
import test.testtools
3 years ago
3 years ago
HOME_PATH = test.constants.HOME_PATH
DATA_PATH = test.constants.DATA_PATH
TEST_FUNCTIONS = ["test_getFiles", "test_pathTool", "test_encoding"]
3 years ago
class MyTestCase(unittest.TestCase):
mymsg = ""
def test_getFiles(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
r = t.getFiles(job.m, job.conf.getPath("program") + "/utils", "^file_.*.py", None)
self.assertEqual(len(r), 1)
cnttest += 3
r = t.getFiles(job.m, job.conf.getPath("program") + "/utils", "^file__.*.py", None)
self.assertEqual((len(r) == 0), True)
r = t.getFiles(job.m, job.conf.getPath("program") + "/utils", ".*_tool.py", None)
self.assertEqual((len(r) > 2), True)
cnttest += 3
r = t.getFilesRec(job.m, job.conf.getPath("program"), ".*?file.*.py")
MyTestCase.mymsg += "\n----- " + actfunction + " : " + str(cnttest)
3 years ago
def test_pathTool(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
#self.assertEqual(utils.path_tool.generatePath("program", "komp", "testA", "CONFIG.yml"),
# os.path.join(HOME_PATH, "components","testA","COFIG.yml"))
MyTestCase.mymsg += "\n----- " + actfunction + " : " + str(cnttest)
def test_encoding(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
print("------- test_encoding")
encodings = ['utf-8', 'windows-1250', 'iso-8859-1']
res = utils.file_tool.getFileEncoding(job.m, os.path.join(DATA_PATH, "tdata", "encoded_iso8859.txt"))
self.assertEqual(res, "iso-8859-1")
res = utils.file_tool.getFileEncoding(job.m, os.path.join(DATA_PATH, "tdata", "encoded_win1250.txt"))
self.assertEqual(res, "iso-8859-1")
res = utils.file_tool.getFileEncoding(job.m, os.path.join(DATA_PATH, "tdata", "encoded_utf8.txt"))
self.assertEqual(res, "utf-8")
cnttest += 3
MyTestCase.mymsg += "\n----- " + actfunction + " : " + str(cnttest)
def test_zzz(self):
print(MyTestCase.mymsg)
3 years ago
if __name__ == '__main__':
unittest.main()