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.

68 lines
2.6 KiB

import unittest
import inspect
import basic.program
import basic.toolHandling
import test.constants
import basic.component
import basic.constants as B
HOME_PATH = test.constants.HOME_PATH
conf = {}
# the list of TEST_FUNCTIONS defines which function will be really tested.
# if you minimize the list you can check the specific test-function
TEST_FUNCTIONS = ["test_01toolhandling"]
#TEST_FUNCTIONS = ["test_01toolhandling"]
# with this variable you can switch prints on and off
verbose = False
class MyTestCase(unittest.TestCase):
def runTest(self):
self.test_toolhandling()
def test_01toolhandling(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = basic.program.Job("unit")
args = {B.PAR_APP: "TEST", B.PAR_ENV: "ENV01", "modus": "unit", "loglevel": "debug", "tool": "config_tool",
"modus": "unit"}
job.par.setParameterArgs(job, args)
#t = basic.toolHandling.ToolManager()
comp = basic.component.Component()
comp.name = "testb"
comp.conf = {}
comp.conf[B.TOPIC_CONN] = {}
comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_CLI] = {}
#self.assertRaises(LookupError, basic.toolHandling.getDbTool, comp)
comp = basic.component.Component()
comp.name = "testb"
comp.conf = {}
comp.conf[B.SUBJECT_ARTIFACT] = {}
comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_API] = {}
comp.conf[B.TOPIC_CONN] = {}
comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB] = {}
comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_CLI] = {}
comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB][B.ATTR_TYPE] = "mysql"
comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_CLI][B.ATTR_TYPE] = "ssh"
tool = basic.toolHandling.getDbTool(job, comp)
self.assertRegex(str(type(tool)), 'dbmysql_tool.DbFcts')
tool = basic.toolHandling.getCliTool(job, comp)
self.assertRegex(str(type(tool)), 'clissh_tool.CliFcts')
comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_FILE] = {}
comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_FILE][B.ATTR_TYPE] = "xml"
2 years ago
tool = basic.toolHandling.getFileTool(job, comp)
self.assertRegex(str(type(tool)), 'filexml_tool.FileFcts')
comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB][B.ATTR_TYPE] = "dxx"
comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_CLI][B.ATTR_TYPE] = "sxx"
self.assertRaises(FileNotFoundError, basic.toolHandling.getDbTool, job, comp)
self.assertRaises(FileNotFoundError, basic.toolHandling.getCliTool, job, comp)
2 years ago
if __name__ == '__main__':
unittest.main()