import unittest, os import basic.program import utils.path_tool import basic.toolHandling import test.constants import components.component import basic.constants as B HOME_PATH = test.constants.HOME_PATH conf = {} class MyTestCase(unittest.TestCase): 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[B.SUBJECT_ARTS] = {} comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB] = {} comp.conf[B.SUBJECT_CONN] = {} comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB] = {} comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][B.ATTR_TYPE] = "shive" tool = basic.toolHandling.getDbTool(comp) self.assertRegex(str(type(tool)), 'dbshive_tool.DbFcts') attr = tool.getDbAttributes("xx") self.assertRegex(attr[B.ATTR_DB_PARTITION], 'n') comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "y" attr = tool.getDbAttributes("xx") self.assertRegex(attr[B.ATTR_DB_PARTITION], 'y') comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "z" attr = tool.getDbAttributes("xx") self.assertRegex(attr[B.ATTR_DB_PARTITION], 'z') # sqls = comp.composeSqlClauses("SELECT * FROM lofts") print(sqls) setattr(job.par, B.PAR_DB_WHERE, "name like !%utz%! and regname = !+reg+!") comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" sqls = comp.composeSqlClauses("SELECT * FROM lofts") print(sqls) setattr(job.par, B.PAR_DB_PARTITION, "BA,FV") sqls = comp.composeSqlClauses("SELECT * FROM lofts") print(sqls) tool.deleteRows("deltable") tool.selectRows("deltable") if __name__ == '__main__': unittest.main()