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.
 
 
 

101 lines
3.5 KiB

#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import unittest
import os
import inspect
import utils.path_tool
import basic.program
import basic.constants as B
import test.constants
import test.testtools
import utils.path_const as P
import utils.i18n_tool
import basic.constants as B
import utils.data_const as D
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_01class", "test_02text", "test_03aliasList"]
#TEST_FUNCTIONS = [ "test_03aliasList"]
verbose = False
EXP_KEY_MISSING = "key is missing {}"
EXP_KEY_DOESNT_EXIST = "key doesnt exist in domain {}"
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def test_01class(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
i18n = utils.i18n_tool.I18n.getInstance(job)
self.assertIsNotNone(i18n)
cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_02text(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
job.conf["language"] = "de"
i18n = utils.i18n_tool.I18n.getInstance(job)
res = i18n.getText(f"{EXP_KEY_MISSING=}", job)
if verbose: print("RESULT "+res)
self.assertEqual(res, "Schluesselwort fehlt {}")
cnttest += 1
res = i18n.getText(f"{EXP_KEY_DOESNT_EXIST=}", job)
if verbose: print("RESULT "+res)
self.assertEqual(res, "key doesnt exist in domain {}")
cnttest += 1
res = i18n.getText(f"{B.SUBJECT_PROJECT=}", job)
if verbose: print("RESULT "+res)
self.assertEqual(res, "project")
cnttest += 1
job.conf["language"] = "fr"
i18n = utils.i18n_tool.I18n.getInstance(job)
self.assertRaises(Exception, i18n.getText, (f"{EXP_KEY_MISSING=}", job))
cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_03aliasList(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
job.conf["language"] = "de"
i18n = utils.i18n_tool.I18n.getInstance(job)
# i18n.getText("EXP_KEY_MISSING", EXP_KEY_MISSING, job)
res = i18n.getAliasList(f"{EXP_KEY_MISSING=}", job)
if verbose: print("RESULT "+str(res))
self.assertEqual(res, ['key is missing {}', 'key is missing {}', 'Schluesselwort fehlt {}'])
cnttest += 1
res = i18n.getAliasList(f"{D.DATA_ATTR_ALIAS=}", job)
if verbose: print("RESULT "+str(res))
self.assertEqual(res, ["_alias"])
cnttest += 1
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_zzz(self):
if verbose: print(MyTestCase.mymsg)
if __name__ == '__main__':
verbose = True
unittest.main()