import unittest, os import basic.program import utils.path_tool import basic.toolHandling import test.constants import components.component HOME_PATH = test.constants.HOME_PATH conf = {} class MyTestCase(unittest.TestCase): def runTest(self): self.test_toolhandling() def test_toolhandling(self): job = basic.program.Job("unit") args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "config_tool", "modus": "unit"} job.par.setParameterArgs(args) #t = basic.toolHandling.ToolManager() comp = components.component.Component() comp.name = "testb" comp.conf = {} comp.conf["conn"] = {} self.assertRaises(LookupError, basic.toolHandling.getDbTool, comp) comp = components.component.Component() comp.name = "testb" comp.conf = {} comp.conf["conn"] = {} comp.conf["conn"]["dbtype"] = "mysql" comp.conf["conn"]["clitype"] = "ssh" tool = basic.toolHandling.getDbTool(comp) self.assertRegex(str(type(tool)), 'dbmysql_tool.DbFcts') tool = basic.toolHandling.getCliTool(comp) self.assertRegex(str(type(tool)), 'clissh_tool.CliFcts') comp.conf["conn"]["dbtype"] = "dxx" comp.conf["conn"]["clitype"] = "sxx" self.assertRaises(FileNotFoundError, basic.toolHandling.getDbTool, comp) self.assertRaises(FileNotFoundError, basic.toolHandling.getCliTool, comp) if __name__ == '__main__': unittest.main()