diff --git a/basic/Testserver.py b/basic/Testserver.py index 3e94eaf..e827c0c 100644 --- a/basic/Testserver.py +++ b/basic/Testserver.py @@ -21,11 +21,11 @@ class Testserver(basic.component.Component): self.m = job.m self.conf = {} if B.TOPIC_NODE_DB in job.conf: - self.conf[B.SUBJECT_CONN] = {} - self.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB] = {} + self.conf[B.TOPIC_CONN] = {} + self.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB] = {} for attr in B.LIST_DB_ATTR: if attr in job.conf[B.TOPIC_NODE_DB]: - self.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][attr] = job.conf[B.TOPIC_NODE_DB][attr] + self.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB][attr] = job.conf[B.TOPIC_NODE_DB][attr] if not B.DATA_NODE_DDL in self.conf: self.conf[B.DATA_NODE_DDL] = {} for table in COMP_TABLES: @@ -61,7 +61,7 @@ class Testserver(basic.component.Component): dbi = basic.toolHandling.getDbTool(job, self, job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE]) else: return "No DB in job-config" - path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM], "model") + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_PROGRAM], "model") fct = basic.toolHandling.getFileTool(job, None, "csv") for m in sorted(os.listdir(path)): if not re.match(r".*?\.csv", m): diff --git a/basic/compexec.py b/basic/compexec.py index f681830..5fc1ef2 100644 --- a/basic/compexec.py +++ b/basic/compexec.py @@ -80,12 +80,12 @@ class Testexecuter(): self.m.debug(verify, "--- "+str(inspect.currentframe().f_code.co_name)+"() started at " + datetime.now().strftime("%Y%m%d_%H%M%S")+" for " + str(self.name).upper()) for node in [B.TOPIC_NODE_DB, B.TOPIC_NODE_CLI, B.TOPIC_NODE_API]: - if node not in self.conf[B.SUBJECT_ARTS]: + if node not in self.conf[B.SUBJECT_ARTIFACT]: continue tool = basic.toolHandling.getTool(node, self, job) tool.reset_TData(job) - if B.TOPIC_NODE_FILE in self.conf[B.SUBJECT_ARTS]: - for file in self.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_FILE]: + if B.TOPIC_NODE_FILE in self.conf[B.SUBJECT_ARTIFACT]: + for file in self.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_FILE]: if file in B.LIST_FILE_ATTR: continue print("91: "+self.classname+" "+file) @@ -107,7 +107,7 @@ class Testexecuter(): self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper()) for node in [B.TOPIC_NODE_DB, B.TOPIC_NODE_CLI, B.TOPIC_NODE_FILE, B.TOPIC_NODE_API]: print(node) - if B.TOPIC_NODE_DB in self.conf[B.SUBJECT_ARTS] and B.DATA_NODE_TABLES in tdata: + if B.TOPIC_NODE_DB in self.conf[B.SUBJECT_ARTIFACT] and B.DATA_NODE_TABLES in tdata: for t in tdata[B.DATA_NODE_TABLES]: print (t) if tools.db_abstract.isCompTable(self, job, tdata, t): @@ -137,7 +137,7 @@ class Testexecuter(): #job = basic.program.Job.getInstance() verify = -1+job.getDebugLevel(self.name) self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper()) - if B.TOPIC_NODE_DB in self.conf[B.SUBJECT_ARTS]: + if B.TOPIC_NODE_DB in self.conf[B.SUBJECT_ARTIFACT]: self.m.logInfo("select db-content "+ self.name) dbi = basic.toolHandling.getDbTool(job, self) data = dbi.selectTables(subdir, job) @@ -147,7 +147,7 @@ class Testexecuter(): utils.tdata_tool.writeCsvData( utils.path_tool.rejoinPath(utils.path_tool.composePattern(job, "{tcresult}", self), subdir, t+".csv"), data, self, job) - if B.ATTR_ARTS_LOB in self.conf[B.SUBJECT_ARTS]: + if B.ATTR_ARTS_LOB in self.conf[B.SUBJECT_ARTIFACT]: self.m.logInfo("check lob if is deleted with flaskdb "+ self.name) self.m.setMsg("readInstance for " + self.name + " is OK") self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() finished at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper()) @@ -254,14 +254,14 @@ class Testexecuter(): raise Exception(self.m.getMessageText(job, T.EXP_KEY_DOESNT_EXIST, [step.fct, self.name])) if step.fct in self.conf[B.DATA_NODE_STEPS]: for stepconf in self.conf[B.DATA_NODE_STEPS][step.fct]: - if stepconf[B.SUBJECT_TOOL] == B.TOPIC_NODE_FILE: + if stepconf[B.TOPIC_TOOL] == B.TOPIC_NODE_FILE: tool = basic.toolHandling.getFileTool(job, self, stepconf[B.ATTR_ARTS_TYPE]) print("file-tool") - elif stepconf[B.SUBJECT_TOOL] == B.TOPIC_NODE_API: + elif stepconf[B.TOPIC_TOOL] == B.TOPIC_NODE_API: print("api-tool") - elif stepconf[B.SUBJECT_TOOL] == B.TOPIC_NODE_CLI: + elif stepconf[B.TOPIC_TOOL] == B.TOPIC_NODE_CLI: print("cli-tool") - elif stepconf[B.SUBJECT_TOOL] == B.TOPIC_NODE_DB: + elif stepconf[B.TOPIC_TOOL] == B.TOPIC_NODE_DB: print("db-tool") else: print("nichts da") @@ -297,14 +297,14 @@ class Testexecuter(): """ #job = basic.program.Job.getInstance() verify = job.getDebugLevel(self.name) - if B.ATTR_ARTS_LOG in self.conf[B.SUBJECT_ARTS]: - self.m.logInfo("get files in for "+ self.name + " in " + self.conf[B.SUBJECT_ARTS][B.ATTR_ARTS_LOG]["path"]) - if "flaskdb" in self.conf[B.SUBJECT_ARTS]: + if B.ATTR_ARTS_LOG in self.conf[B.SUBJECT_ARTIFACT]: + self.m.logInfo("get files in for " + self.name + " in " + self.conf[B.SUBJECT_ARTIFACT][B.ATTR_ARTS_LOG]["path"]) + if "flaskdb" in self.conf[B.SUBJECT_ARTIFACT]: self.m.logInfo("select flaskdb-content "+ self.name) - if B.ATTR_ARTS_LOB in self.conf[B.SUBJECT_ARTS]: + if B.ATTR_ARTS_LOB in self.conf[B.SUBJECT_ARTIFACT]: pass # after selection get file from flaskdb - if B.ATTR_ARTS_FILE in self.conf[B.SUBJECT_ARTS]: - self.m.logInfo("get files in for "+ self.name + " in " + self.conf[B.SUBJECT_ARTS][B.ATTR_ARTS_FILE]["path"]) + if B.ATTR_ARTS_FILE in self.conf[B.SUBJECT_ARTIFACT]: + self.m.logInfo("get files in for " + self.name + " in " + self.conf[B.SUBJECT_ARTIFACT][B.ATTR_ARTS_FILE]["path"]) self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name)) @@ -317,14 +317,14 @@ class Testexecuter(): #job = basic.program.Job.getInstance() verify = job.getDebugLevel(self.name) self.m.debug(verify, "--- "+str(inspect.currentframe().f_code.co_name)+"() "+str(self.name)) - if B.ATTR_ARTS_LOG in self.conf[B.SUBJECT_ARTS]: + if B.ATTR_ARTS_LOG in self.conf[B.SUBJECT_ARTIFACT]: pass # - if "flaskdb" in self.conf[B.SUBJECT_ARTS]: + if "flaskdb" in self.conf[B.SUBJECT_ARTIFACT]: pass # stored in table - if B.ATTR_ARTS_LOB in self.conf[B.SUBJECT_ARTS]: - self.m.logInfo("tidy files in for "+self.name+" in "+self.conf[B.SUBJECT_ARTS][B.ATTR_ARTS_LOB]["format"]) - if B.ATTR_ARTS_FILE in self.conf[B.SUBJECT_ARTS]: - self.m.logInfo("tidy files in for "+self.name+" in "+self.conf[B.SUBJECT_ARTS][B.ATTR_ARTS_FILE]["format"]) + if B.ATTR_ARTS_LOB in self.conf[B.SUBJECT_ARTIFACT]: + self.m.logInfo("tidy files in for " + self.name +" in " + self.conf[B.SUBJECT_ARTIFACT][B.ATTR_ARTS_LOB]["format"]) + if B.ATTR_ARTS_FILE in self.conf[B.SUBJECT_ARTIFACT]: + self.m.logInfo("tidy files in for " + self.name +" in " + self.conf[B.SUBJECT_ARTIFACT][B.ATTR_ARTS_FILE]["format"]) def fix_TcResult(self, job, granularity): """ @@ -350,15 +350,15 @@ class Testexecuter(): cm = basic.componentHandling.ComponentManager.getInstance(job) data = {} matching = utils.match_tool.Matching(job, self) - if B.TOPIC_NODE_DB in self.conf[B.SUBJECT_ARTS]: - for t in self.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB]: + if B.TOPIC_NODE_DB in self.conf[B.SUBJECT_ARTIFACT]: + for t in self.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB]: if t in B.LIST_DB_ATTR: continue # fill each data into matching-object for side in M.MATCH_SIDES: if side == M.MATCH_SIDE_PRESTEP: - if B.ATTR_ARTS_PRESTEP in self.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][t]: - a = self.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][t][B.ATTR_ARTS_PRESTEP].split(":") + if B.ATTR_ARTS_PRESTEP in self.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB][t]: + a = self.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB][t][B.ATTR_ARTS_PRESTEP].split(":") if a[0] != self.name: comp = cm.getComponent(a[0]) else: diff --git a/basic/component.py b/basic/component.py index 866f382..79f9caf 100644 --- a/basic/component.py +++ b/basic/component.py @@ -35,8 +35,6 @@ def syncEnitity(job, elem): :return: """ syncMethod = DEFAULT_SYNC - if B.SUBJECT_ENTITY in job.conf: - syncMethod = job.conf["entity"][TABLE_NAMES[0]]["storage"] if syncMethod.count("-") < 2: return fileTime = basic.entity.VAL_ZERO_TIME @@ -44,7 +42,7 @@ def syncEnitity(job, elem): # get git-commit if "git" in syncMethod: comppath = tools.config_tool.select_config_path(job, P.KEY_COMP, elem) - repopath = comppath[len(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS]) + 1:] + repopath = comppath[len(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS]) + 1:] gitresult = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, repopath, 1) fileTime = gitresult[0]["date"] print(str(gitresult)) diff --git a/basic/componentHandling.py b/basic/componentHandling.py index 4ecaa4b..f910cfd 100644 --- a/basic/componentHandling.py +++ b/basic/componentHandling.py @@ -26,7 +26,7 @@ import basic.constants as B import tools.data_const as D comps = {} -PARAM_NOSUBNODE = [B.SUBJECT_ARTS, "components", "instance"] +PARAM_NOSUBNODE = [B.SUBJECT_ARTIFACT, "components", "instance"] DEFAULT_INST_CNT = 1 DEFAULT_INST_SGL = "y" @@ -41,10 +41,10 @@ def getInstanceAttributes(conf): B.ATTR_INST_CNT: DEFAULT_INST_CNT, B.ATTR_INST_SGL: DEFAULT_INST_SGL } - if B.SUBJECT_INST in conf: + if B.TOPIC_INST in conf: for attr in [B.ATTR_INST_CNT, B.ATTR_INST_SGL]: - if attr in conf[B.SUBJECT_INST]: - out[attr] = conf[B.SUBJECT_INST][attr] + if attr in conf[B.TOPIC_INST]: + out[attr] = conf[B.TOPIC_INST][attr] return out @@ -89,7 +89,7 @@ class ComponentManager: job.m.setFatal("application " + job.par.application + " is not configured") return for k in job.conf[B.SUBJECT_APPS].get(anw): - if k == B.ATTR_APPS_PROJECT: + if k == B.SUBJECT_PROJECT: continue job.m.logDebug("applicationscomponente -- " + k + ":") print("applicationscomponente -- " + k + ":") @@ -191,17 +191,17 @@ class ComponentManager: c.m = basic.message.Message(job, basic.message.LIMIT_DEBUG, job.start, c.name) c.conf = tools.config_tool.mergeConn(c.m, confs["conf"], conns[i]) - c.conf[B.SUBJECT_CONN] = conns[i] + c.conf[B.TOPIC_CONN] = conns[i] c.init(job) if parContent is not None: print("createComponent 5 a " + compName + " : " + str(parContent)) if B.SUBJECT_COMPS in parContent and compName in parContent[B.SUBJECT_COMPS]: for k in parContent[B.SUBJECT_COMPS][compName].keys(): c.conf[k] = parContent[B.SUBJECT_COMPS][compName][k] - if B.SUBJECT_ARTS in c.conf and B.TOPIC_NODE_DB in c.conf[B.SUBJECT_ARTS]: + if B.SUBJECT_ARTIFACT in c.conf and B.TOPIC_NODE_DB in c.conf[B.SUBJECT_ARTIFACT]: if not B.DATA_NODE_DDL in c.conf: c.conf[B.DATA_NODE_DDL] = {} - for table in c.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB]: + for table in c.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB]: if table in B.LIST_DB_ATTR: continue conf = tools.config_tool.getConfig(job, D.DDL_FILENAME, compName, table) diff --git a/basic/constants.py b/basic/constants.py index 377a978..1c1db35 100644 --- a/basic/constants.py +++ b/basic/constants.py @@ -20,16 +20,330 @@ The constants desribes the keywords of the main datastructures, these are """ import os +home = "" +if home == "": + home = os.getcwd() + prgdir = "" + if home[-4:] == "test": + home = home[0:-5] + if home[-10:] == "components": + home = home[0:-11] + if home[-9:] == "program": + prgdir = home[-6:] + home = home[0:-7] + elif home[-7:] == "program": + prgdir = home[-7:] + home = home[0:-8] + HOME_PATH = home + + # -- example ----------------------------------------------------- + # example testcase - nodes + # the internal datastructure is a tree with this design: + # root { : subject itself - subject-singular-constant + # + option { : subtable of subject - subject-plural-constant + # + attribute : attribute of subtable - allowed attribute-names in data-const LIST_ATTR_ + # + stories : subtable of subject + # + : element of subtable - the unique name + # + name : redundant name-attribute + # + attribute : some main attributes + # + datas : + # + : table name + # + ddl : topic, functionality relating to ddl + # + _header [ : specific data-node of the topic - constant + # - fields : variable field-name + # + steps : special topic + # + # + comp { : variable component-name + # + substructure { : variable maybe scheme, table of a database-component + # + + _header [ : constant + # - fields : variable field-name + # ------------------------------------------------------------- + + # --Domain ---------------------------------------------------- + # ____ _ + # | _ \ ___ _ __ ___ __ _(_)_ __ + # | | | |/ _ \| '_ ` _ \ / _` | | '_ \ + # | |_| | (_) | | | | | | (_| | | | | | + # |____/ \___/|_| |_| |_|\__,_|_|_| |_| + # + # ------------------------------------------------------------- + DOM_PROJECT = "project" + """ + this domain is relating to project-management and -knowledge + subjects of the domain are: + - project + - application + - release + topics relating to the domain are: + """ +DOM_SPECIFICATION = "specification" +""" +this domain is relating to project-management and -knowledge +subjects of the domain are: +- application + - usercase + - variant +- release + - story +topics relating to the domain are: +""" +DOM_TEST = "test" +""" +this domain is relating to project-management and -knowledge +subjects of the domain are: +- testplan + - release +- testsuite + - application + - variant +- testcase + - application + - usercase + - variant + - story + - option + - data + - step +- testreport + - release + - artifact +topics relating to the domain are: +""" +DOM_IMPLEMENTATION = "implementation" +""" +this domain is relating to project-management and -knowledge +subjects of the domain are: +- component + - artifact + - data + - step +topics relating to the domain are: +- db +- cli +- api +- conn +- ddl +""" +DOM_INSTALLATION = "installation" +""" +this domain is relating to project-management and -knowledge +subjects of the domain are: +- environent + - component +topics relating to the domain are: +- db +- cli +- api +- conn +- instance +""" + +# --Subject ---------------------------------------------------- +# ____ _ _ _ +# / ___| _ _| |__ (_) ___ ___| |_ +# \___ \| | | | '_ \| |/ _ \/ __| __| +# ___) | |_| | |_) | | __/ (__| |_ +# |____/ \__,_|_.__// |\___|\___|\__| +# |__/ # ------------------------------------------------------------- -# values and keywords -BASIS_FILE = "basis" +# the configuration of a component or tool +# entity { : variable name of the group, xbasic, component-name or tool-name +# + subject { : variable subject-name - it correspondends to a tool +# + + sub-subject { : variable subject-name - it correspondends to a tool +# + attributes : constant of the tool in which the attribute ist implemented +# the main subjects # prog xbasic envir tool comp testcase main implentation module +""" This constant defines the debug-folder in testing-filesystem """ +SUBJECT_PROJECT = "project" +SUBJECT_PROJECTS = SUBJECT_PROJECT + "s" +SUBJECT_APP = "application" +SUBJECT_APPS = "applications" # +SUBJECT_COMP = "component" +SUBJECT_COMPS = SUBJECT_COMP + "s" +SUBJECT_USECASE = "usecase" +SUBJECT_USECASES = SUBJECT_USECASE + "s" +SUBJECT_REL = "release" +SUBJECT_RELS = SUBJECT_REL + "s" +SUBJECT_TESTCASE = "testcase" +SUBJECT_TESTCASES = SUBJECT_TESTCASE + "s" +SUBJECT_TESTSUITE = "testsuite" +SUBJECT_TESTSUITES = SUBJECT_TESTSUITE + "s" +SUBJECT_TESTPLAN = "testplan" +SUBJECT_TESTPLANS = SUBJECT_TESTPLAN + "s" +SUBJECT_ARTIFACT = "artifact" +SUBJECT_ARTIFACTS = SUBJECT_ARTIFACT + "s" +ATTR_ARTS_LOG = "log" +ATTR_ARTS_LOB = "lob" +ATTR_ARTS_FILE = "file" +ATTR_ARTS_TYPE = "type" +""" must attribute for the type of the technique """ +ATTR_ARTS_NAME = "name" +""" optional attribute just for information """ +ATTR_ARTS_PATH = "path" +""" optional attribute for the xbasic folder if the artifact is stored in the filesystem """ +ATTR_ARTS_RESET = "reset" +""" optional attribute if the artefact should be reset in the initializing-phase """ +ATTR_ARTS_PRESTEP = "prestep" +""" optional attribute to define a source-table for this table """ +LIST_ARTS_ATTR = [ATTR_ARTS_TYPE, ATTR_ARTS_PATH, ATTR_ARTS_RESET, ATTR_ARTS_PRESTEP, ATTR_ARTS_NAME] +SUBJECT_VARIANTS = "variants" +SUBJECT_ENVIRONMENT = 'environment' +SUBJECT_ENVIRONMENTS = SUBJECT_ENVIRONMENT + "s" +SUBJECT_STORY = "story" +SUBJECT_STORIES = "stories" +SUBJECT_DESCRIPTION = "description" # --> MAIN-ATTR +SUBJECT_REFERENCE = "reference" # --> MAIN-ATTR +LIST_SUBJECTS = [SUBJECT_APPS, SUBJECT_ARTIFACT, SUBJECT_COMPS, SUBJECT_PROJECTS] -SVAL_YES = "y" -SVAL_NO = "n" -SVAL_NULL = "null" +# --Topic ----------------------------------------------------- +# _____ _ +# |_ _|__ _ __ (_) ___ +# | |/ _ \| '_ \| |/ __| +# | | (_) | |_) | | (__ +# |_|\___/| .__/|_|\___| +# |_| +# ------------------------------------------------------------- +# topics +""" + in this subject-node are each kind of result of any component with the structure: + * topic (db, cli, api, ...) + * * general attributes - to-know: technical attributes are stored in connection-tree + * * partial-component - to-know: the existence of db-tables can be defined in the ddl-tree + * * * specific attributes - it overrides the general attributes +""" +TOPIC_INST = "instance" +ATTR_INST_CNT = "count" # +ATTR_INST_SGL = "single" +LIST_INST_ATTR = [ATTR_INST_CNT, ATTR_INST_SGL] +ATTR_INST_SUBCOMP = SUBJECT_COMPS +ATTR_INST_TESTSERVER = "Testserver" +TOPIC_PATH = "paths" +ATTR_PATH_MODE = "mode" +""" This constant defines the home-folder in filesystem of test """ +ATTR_PATH_HOME = "home" +""" This constant defines the home-folder in testing-filesystem """ +ATTR_PATH_DEBUG = "debugs" +""" This constant defines the debug-folder in testing-filesystem """ +ATTR_PATH_ARCHIV = "archiv" +""" This constant defines the folder in testing-filesystem for results and log of execution """ +ATTR_PATH_EXPECT = "expect" +""" This constant defines the folder in testing-filesystem for test-expectation values """ +ATTR_PATH_PROGRAM = "program" +""" This constant defines the program-folder in the workspace """ +ATTR_PATH_COMPS = "components" +""" This constant defines the subfolder in the program-folder in the workspace """ +ATTR_PATH_ENV = "environment" +""" This constant defines the folder in testing-filesystem, used for configs related to environments """ +ATTR_PATH_RELEASE = "release" +""" This constant defines the folder in testing-filesystem, used for configs related to release """ +ATTR_PATH_TDATA = "testdata" +""" This constant defines the folder in testing-filesystem with the testcase-specifications """ +ATTR_PATH_PATTN = "pattern" +""" This constant defines the debug-folder in testing-filesystem """ +# SUBJECT_FCT = "function" # --> TOPIC +TOPIC_DDL = "ddl" +ATTR_TYPE = "type" # +RULE_ACCEPTANCE = "acceptance" # +ATTR_STEP_ARGS = "args" +ATTR_EXEC_REF = "_exec" +ATTR_DATA_REF = "_nr" +ATTR_DATA_COMP = "_comp" +TOPIC_TOOL = "tool" # ?? -> TOPIC +TOPIC_NODE_DB = "db" +# testexec, db_abstr +ATTR_DB_PARTITION = "partitioned" +""" optional attribute if table is partitioned + - this keyword delimited by "+" will be replaced by partition-names which are parametrized """ +ATTR_DB_DATABASE = "database" +""" attribute for technical name of the database """ +ATTR_DB_SCHEMA = "schema" +""" optional attribute for technical name of the schema """ +ATTR_DB_TABNAME = "tabname" +""" optional attribute in order to use a different technical name for the db-table """ +ATTR_DB_USER = "user" +""" optional attribute in order to use a different technical name for the db-table """ +ATTR_DB_PASSWD = "password" +""" optional attribute in order to use a different technical name for the db-table """ +ATTR_DB_HOST = "hostname" +""" optional attribute in order to use a different technical name for the db-table """ +LIST_DB_ATTR = [ATTR_DB_PARTITION, ATTR_DB_DATABASE, ATTR_DB_SCHEMA, ATTR_DB_TABNAME, ATTR_ARTS_PRESTEP, + ATTR_DB_USER, ATTR_DB_PASSWD, ATTR_DB_HOST] + LIST_ARTS_ATTR +TOPIC_CONN = "conn" +ATTR_DB_CONN_JAR = "conn_jar_name" +""" optional attribute for connection-jar-file instead of connection by ip, port """ +ATTR_CONN_HOST = "hostname" +""" optional attribute for connection-jar-file instead of connection by ip, port """ +ATTR_CONN_TENANT = "tenant" +""" optional attribute for connection-jar-file instead of connection by ip, port """ +ATTR_CONN_IP = "ip" +ATTR_CONN_PORT = "port" +ATTR_CONN_DOMPATH = "dompath" +""" directory where the component is stored in the filesystem """ +ATTR_CONN_USER = "user" +ATTR_CONN_PASSWD = "password" +LIST_CONN_ATTR = [ATTR_CONN_HOST, ATTR_CONN_IP, ATTR_CONN_PORT, ATTR_CONN_DOMPATH, ATTR_CONN_USER, ATTR_CONN_PASSWD] +TOPIC_NODE_CLI = "cli" +LIST_CLI_ATTR = [] + LIST_ARTS_ATTR +TOPIC_NODE_API = "api" +LIST_API_ATTR = [] + LIST_ARTS_ATTR +TOPIC_NODE_FILE = "file" +ATTR_FILE_OLD = "oldfile" +ATTR_FILE_ROTATE = "rotate" +NODE_ATTRIBUTES = "attributes" +LIST_FILE_ATTR = [ATTR_FILE_OLD, ATTR_FILE_ROTATE] + LIST_ARTS_ATTR +LIST_ATTR = { + TOPIC_NODE_DB: LIST_DB_ATTR, + TOPIC_NODE_API: LIST_API_ATTR, + TOPIC_NODE_CLI: LIST_CLI_ATTR, + TOPIC_NODE_FILE: LIST_FILE_ATTR +} +LIST_TOPIC_NODES = [TOPIC_NODE_FILE, TOPIC_NODE_DB, TOPIC_NODE_CLI, TOPIC_NODE_API] +# -- data nodes ----------------------------------------------- +# ____ _ _ _ _ +# | _ \ __ _| |_ __ _ | \ | | ___ __| | ___ ___ +# | | | |/ _` | __/ _` |_____| \| |/ _ \ / _` |/ _ \/ __| +# | |_| | (_| | || (_| |_____| |\ | (_) | (_| | __/\__ \ +# |____/ \__,_|\__\__,_| |_| \_|\___/ \__,_|\___||___/ +# +# ------------------------------------------------------------- +""" This constant defines a subnode of a table for the column-names """ +CONF_NODE_GENERAL = "_general" +""" it defines a subnode of a table for the column-names """ +DATA_NODE_HEADER = "_header" +""" it defines a subnode of a table for the field-list, used for ddl """ +DATA_NODE_FIELDS = "_fields" +""" it defines a subnode of a table for the data as key-value-pair, keys from header """ +DATA_NODE_DATA = "_data" +""" it defines the main node in the testdata for the steps to execute """ +DATA_NODE_STEPS = "_step" ## ?? SUBJECT +""" it defines main node in the testdata for testcase specific parameters """ +DATA_NODE_OPTION = "_option" ## ?? SUBJECT +DATA_NODE_HEAD = "_head" ## ?? +DATA_NODE_ARGS = "_arguments" +""" it defines arguments as internal key-value-pairs by delimted with :, used in steps """ +""" This constant defines the main node in the testdata for the steps to execute """ +DATA_NODE_TABLES = "_tables" # ?? SUBJECT +DATA_NODE_KEYS = "_keys" +""" This constant defines the node for data scheme (DataDefinitionLanguage) +The fields are defined in data_const (D) """ +DATA_NODE_DDL = "ddl" # ?? TOPIC +DATA_NODE_COMP = "comp" # ?? SUBJECT +""" This constant defines """ +DATA_NODE_PAR = "par" +DATA_NODE_CATALOG = "_catalog" +DATA_NODE_ROW = "_row" +DATA_NODE_SUBTABLES = "subtables" # ?? SUBJECT +LIST_DATA_NODE = [DATA_NODE_HEADER, DATA_NODE_DATA, DATA_NODE_DDL, + DATA_NODE_TABLES, DATA_NODE_STEPS, DATA_NODE_OPTION, DATA_NODE_ROW] + +# -- Parameter ------------------------------------------------ +# ____ _ +# | _ \ __ _ _ __ __ _ _ __ ___ ___| |_ ___ _ __ +# | |_) / _` | '__/ _` | '_ ` _ \ / _ \ __/ _ \ '__| +# | __/ (_| | | | (_| | | | | | | __/ || __/ | +# |_| \__,_|_| \__,_|_| |_| |_|\___|\__\___|_| +# # ------------------------------------------------------------- -# parameter with arguments PAR_PROGRAM = 'program' PAR_USER = 'user' PAR_GRAN = "gran" @@ -80,227 +394,32 @@ PAR_DB_WHERE = "dbwhere" PAR_DB_PARTITION = "dbparts" """ optional parameter for partitions of a partitioned tables """ LIST_MAIN_PAR = [PAR_APP, PAR_ENV, PAR_VAR, PAR_REL, PAR_TCDIR, PAR_TSDIR] -# ------------------------------------------------------------- -# attributes +# -- attributes ----------------------------------------------- +# _ _ _ _ _ +# __ _| |_| |_ _ __(_) |__ _ _| |_ ___ ___ +# / _` | __| __| '__| | '_ \| | | | __/ _ \/ __| +# | (_| | |_| |_| | | | |_) | |_| | || __/\__ \ +# \__,_|\__|\__|_| |_|_.__/ \__,_|\__\___||___/ +# # ------------------------------------------------------------- -# structure - nodes -# the internal datastructure is a tree with this design: -# root { : constant -# + option { : constant -# + steps -# + comp { : variable component-name -# + substructure { : variable maybe scheme, table of a database-component -# + + _header [ : constant -# - fields : variable field-name -""" This constant defines a subnode of a table for the column-names """ -CONF_NODE_GENERAL = "_general" -""" it defines a subnode of a table for the column-names """ -DATA_NODE_HEADER = "_header" -""" it defines a subnode of a table for the field-list, used for ddl """ -DATA_NODE_FIELDS = "_fields" -""" it defines a subnode of a table for the data as key-value-pair, keys from header """ -DATA_NODE_DATA = "_data" -""" it defines the main node in the testdata for the steps to execute """ -DATA_NODE_STEPS = "_step" -""" it defines main node in the testdata for testcase specific parameters """ -DATA_NODE_OPTION = "_option" -DATA_NODE_HEAD = "_head" -DATA_NODE_ARGS = "_arguments" -""" it defines arguments as internal key-value-pairs by delimted with :, used in steps """ -""" This constant defines the main node in the testdata for the steps to execute """ -DATA_NODE_TABLES = "_tables" -DATA_NODE_KEYS = "_keys" -""" This constant defines the node for data scheme (DataDefinitionLanguage) -The fields are defined in data_const (D) """ -DATA_NODE_DDL = "ddl" -DATA_NODE_COMP = "comp" -""" This constant defines """ -DATA_NODE_PAR = "par" -DATA_NODE_CATALOG = "_catalog" -DATA_NODE_ROW = "_row" -LIST_DATA_NODE = [DATA_NODE_HEADER, DATA_NODE_DATA, DATA_NODE_DDL, - DATA_NODE_TABLES, DATA_NODE_STEPS, DATA_NODE_OPTION, DATA_NODE_ROW] - -ATTR_ARTS_TYPE = "type" -""" must attribute for the type of the technique """ -ATTR_ARTS_NAME = "name" -""" optional attribute just for information """ -ATTR_ARTS_PATH = "path" -""" optional attribute for the xbasic folder if the artifact is stored in the filesystem """ -ATTR_ARTS_RESET = "reset" -""" optional attribute if the artefact should be reset in the initializing-phase """ -ATTR_ARTS_PRESTEP = "prestep" -""" optional attribute to define a source-table for this table """ -LIST_ARTS_ATTR = [ATTR_ARTS_TYPE, ATTR_ARTS_PATH, ATTR_ARTS_RESET, ATTR_ARTS_PRESTEP, ATTR_ARTS_NAME] -TOPIC_NODE_DB = "db" -# testexec, db_abstr -ATTR_DB_PARTITION = "partitioned" -""" optional attribute if table is partitioned - - this keyword delimited by "+" will be replaced by partition-names which are parametrized """ -ATTR_DB_DATABASE = "database" -""" attribute for technical name of the database """ -ATTR_DB_SCHEMA = "schema" -""" optional attribute for technical name of the schema """ -ATTR_DB_TABNAME = "tabname" -""" optional attribute in order to use a different technical name for the db-table """ -ATTR_DB_USER = "user" -""" optional attribute in order to use a different technical name for the db-table """ -ATTR_DB_PASSWD = "password" -""" optional attribute in order to use a different technical name for the db-table """ -ATTR_DB_HOST = "hostname" -""" optional attribute in order to use a different technical name for the db-table """ -LIST_DB_ATTR = [ATTR_DB_PARTITION, ATTR_DB_DATABASE, ATTR_DB_SCHEMA, ATTR_DB_TABNAME, ATTR_ARTS_PRESTEP, - ATTR_DB_USER, ATTR_DB_PASSWD, ATTR_DB_HOST] + LIST_ARTS_ATTR -TOPIC_NODE_CLI = "cli" -LIST_CLI_ATTR = [] + LIST_ARTS_ATTR -TOPIC_NODE_API = "api" -LIST_API_ATTR = [] + LIST_ARTS_ATTR -TOPIC_NODE_FILE = "file" -ATTR_FILE_OLD = "oldfile" -ATTR_FILE_ROTATE = "rotate" -NODE_ATTRIBUTES = "attributes" - - -LIST_FILE_ATTR = [ATTR_FILE_OLD, ATTR_FILE_ROTATE] + LIST_ARTS_ATTR -LIST_TOPIC_NODES = [TOPIC_NODE_FILE, TOPIC_NODE_DB, TOPIC_NODE_CLI, TOPIC_NODE_API] - -LIST_ATTR = { - TOPIC_NODE_DB: LIST_DB_ATTR, - TOPIC_NODE_API: LIST_API_ATTR, - TOPIC_NODE_CLI: LIST_CLI_ATTR, - TOPIC_NODE_FILE: LIST_FILE_ATTR -} - -ATTR_DB_CONN_JAR = "conn_jar_name" -""" optional attribute for connection-jar-file instead of connection by ip, port """ -ATTR_CONN_HOST = "hostname" -""" optional attribute for connection-jar-file instead of connection by ip, port """ -ATTR_CONN_TENANT = "tenant" -""" optional attribute for connection-jar-file instead of connection by ip, port """ -ATTR_CONN_IP = "ip" -ATTR_CONN_PORT = "port" -ATTR_CONN_DOMPATH = "dompath" -""" directory where the component is stored in the filesystem """ -ATTR_CONN_USER = "user" -ATTR_CONN_PASSWD = "password" -LIST_CONN_ATTR = [ATTR_CONN_HOST, ATTR_CONN_IP, ATTR_CONN_PORT, ATTR_CONN_DOMPATH, ATTR_CONN_USER, ATTR_CONN_PASSWD] - -# the configuration of a component or tool -# entity { : variable name of the group, xbasic, component-name or tool-name -# + subject { : variable subject-name - it correspondends to a tool -# + + sub-subject { : variable subject-name - it correspondends to a tool -# + attributes : constant of the tool in which the attribute ist implemented - -# the main subjects # prog xbasic envir tool comp testcase main implentation module -SUBJECT_PATH = "paths" # | x | | x | | path_tool, config_tool -""" This constant defines the subject in order to define paths of filesystem of any testuse """ -ATTR_PATH_MODE = "mode" -""" This constant defines the home-folder in filesystem of test """ -ATTR_PATH_HOME = "home" -""" This constant defines the home-folder in testing-filesystem """ -ATTR_PATH_DEBUG = "debugs" -""" This constant defines the debug-folder in testing-filesystem """ -ATTR_PATH_ARCHIV = "archiv" -""" This constant defines the folder in testing-filesystem for results and log of execution """ -ATTR_PATH_EXPECT = "expect" -""" This constant defines the folder in testing-filesystem for test-expectation values """ -ATTR_PATH_PROGRAM = "program" -""" This constant defines the program-folder in the workspace """ -ATTR_PATH_COMPS = "components" -""" This constant defines the subfolder in the program-folder in the workspace """ -ATTR_PATH_ENV = "environment" -""" This constant defines the folder in testing-filesystem, used for configs related to environments """ -ATTR_PATH_RELEASE = "release" -""" This constant defines the folder in testing-filesystem, used for configs related to release """ -ATTR_PATH_TDATA = "testdata" -""" This constant defines the folder in testing-filesystem with the testcase-specifications """ -ATTR_PATH_PATTN = "pattern" -""" This constant defines the debug-folder in testing-filesystem """ -SUBJECT_APP = "application" -SUBJECT_APPS = "applications" # | x | | | | CompHandling -ATTR_APPS_PROJECT = "project" # | | | | x | CompHanlding -SUBJECT_ENTITY = "entity" -SUBJECT_INST = "instance" # | | | | x | CompHanlding -ATTR_INST_CNT = "count" # | | | | x | CompHanlding -ATTR_INST_SGL = "single" -LIST_INST_ATTR = [ATTR_INST_CNT, ATTR_INST_SGL] -SUBJECT_COMP = "component" -SUBJECT_COMPS = SUBJECT_COMP+"s" -ATTR_INST_SUBCOMP = SUBJECT_COMPS -ATTR_INST_TESTSERVER = "Testserver" -#SUBJECT_FCT = "function" # | | | | x | main-programs - -SUBJECT_USECASE = "usecase" -SUBJECT_USECASES = SUBJECT_USECASE+"s" - -SUBJECT_REL = "release" -SUBJECT_RELS = SUBJECT_REL+"s" - -SUBJECT_TESTCASE = "testcase" -SUBJECT_TESTCASES = SUBJECT_TESTCASE+"s" - -SUBJECT_TESTSUITE = "testsuite" -SUBJECT_TESTSUITES = SUBJECT_TESTSUITE+"s" - -SUBJECT_TESTPLAN = "testplan" -SUBJECT_TESTPLANS = SUBJECT_TESTPLAN+"s" - -""" -in this subject-node are each kind of result of any component with the structure: - * topic (db, cli, api, ...) - * * general attributes - to-know: technical attributes are stored in connection-tree - * * partial-component - to-know: the existence of db-tables can be defined in the ddl-tree - * * * specific attributes - it overrides the general attributes -""" -SUBJECT_ARTS = "artifact" # | | | | x | Component - -SUBJECT_VARIANTS = "variants" -#ATTR_ARTS_DB = "db" -ATTR_ARTS_LOG = "log" -ATTR_ARTS_LOB = "lob" -ATTR_ARTS_FILE = "file" -#SUBJECT_DB = "databases" # | | | | # | db*_tools, match_tool -SUBJECT_PROJECT = "project" -SUBJECT_PROJECTS = SUBJECT_PROJECT+"s" -SUBJECT_ENV = PAR_ENV -SUBJECT_STORY = "story" -SUBJECT_STORIES = "stories" - -SUBJECT_CONN = "conn" # | | x | | | conn_tool, db*_tools, cli*_toold -ATTR_TYPE = "type" # | x | x | | x | conn_tool, toolHandling, db*_tools - -RULE_ACCEPTANCE = "acceptance" # | | | | x | tools_match - -ATTR_STEP_ARGS = "args" -ATTR_EXEC_REF = "_exec" -ATTR_DATA_REF = "_nr" -ATTR_DATA_COMP = "_comp" - -SUBJECT_DESCRIPTION = "description" -SUBJECT_REFERENCE = "reference" +# -- key-values ----------------------------------------------- +# _ _ +# | | _____ _ ___ ____ _| |_ _ ___ ___ +# | |/ / _ \ | | \ \ / / _` | | | | |/ _ \/ __| +# | < __/ |_| |\ V / (_| | | |_| | __/\__ \ +# |_|\_\___|\__, | \_/ \__,_|_|\__,_|\___||___/ +# |___/ +# ------------------------------------------------------------- +BASIS_FILE = "basis" +SVAL_YES = "y" +SVAL_NO = "n" +SVAL_NULL = "null" -SUBJECT_TOOL = "tool" -LIST_SUBJECTS = [SUBJECT_APPS, SUBJECT_ARTS, SUBJECT_CONN, SUBJECT_COMPS, SUBJECT_INST, SUBJECT_TOOL, SUBJECT_PROJECTS] # ------------------------------------------------------------- # exception texts EXP_NO_BASIS_FILE = "basis file cant be found" - EXCEPT_NOT_IMPLEMENT = "method is not implemented" - EXCEPT_NOT_INITIALIZED = "class is not initialized" -home = os.getcwd() -prgdir = "" -if home[-4:] == "test": - home = home[0:-5] -if home[-10:] == "components": - home = home[0:-11] -if home[-9:] == "program": - prgdir = home[-6:] - home = home[0:-7] -elif home[-7:] == "program": - prgdir = home[-7:] - home = home[0:-8] -HOME_PATH = home diff --git a/basic/message.py b/basic/message.py index 64aa9db..ccc7ce5 100644 --- a/basic/message.py +++ b/basic/message.py @@ -152,7 +152,7 @@ class Message: self.topmessage = "" def openDebug(self, job, logTime, compName): - path = job.conf[B.SUBJECT_PATH][B.ATTR_PATH_DEBUG] + path = job.conf[B.TOPIC_PATH][B.ATTR_PATH_DEBUG] if not os.path.exists(path): os.mkdir(path) logTime = logTime[0:11] + "0000" diff --git a/basic/program.py b/basic/program.py index 3438d2a..5bc81f6 100644 --- a/basic/program.py +++ b/basic/program.py @@ -229,8 +229,8 @@ class Job: print("Logpath: "+self.m.logpath) print(footer1) print(footer2) - if "editor" in self.conf[B.SUBJECT_PATH]: - subprocess.Popen([self.conf[B.SUBJECT_PATH]["editor"], str(self.m.logpath)]) + if "editor" in self.conf[B.TOPIC_PATH]: + subprocess.Popen([self.conf[B.TOPIC_PATH]["editor"], str(self.m.logpath)]) if reboot == 0: exit(rc) @@ -252,7 +252,7 @@ class Job: if x not in cconf[c]: continue output[B.SUBJECT_COMPS][c][x] = cconf[c][x] - if x == B.SUBJECT_CONN and "passwd" in cconf[c][x]: + if x == B.TOPIC_CONN and "passwd" in cconf[c][x]: cconf[B.SUBJECT_COMPS][c][x]["passwd"] = "xxxxx" tools.file_tool.write_file_dict(self.m, self, parpath, output) @@ -464,9 +464,9 @@ class Parameter: dirpath = self.getDirParameter() if hasattr(self, "application") and B.SUBJECT_APPS in job.conf \ and getattr(self, "application") in job.conf[B.SUBJECT_APPS]: - if B.ATTR_APPS_PROJECT in job.conf[B.SUBJECT_APPS][self.application]: - setattr(self, B.ATTR_APPS_PROJECT, job.conf[B.SUBJECT_APPS][self.application][B.ATTR_APPS_PROJECT]) - proj = getattr(self, B.ATTR_APPS_PROJECT) + if B.SUBJECT_PROJECT in job.conf[B.SUBJECT_APPS][self.application]: + setattr(self, B.SUBJECT_PROJECT, job.conf[B.SUBJECT_APPS][self.application][B.SUBJECT_PROJECT]) + proj = getattr(self, B.SUBJECT_PROJECT) def setParameterLoaded(self, job): diff --git a/basic/toolHandling.py b/basic/toolHandling.py index 12c6064..f55614b 100644 --- a/basic/toolHandling.py +++ b/basic/toolHandling.py @@ -41,14 +41,14 @@ Toolmanager def getCompAttr(comp, topic, attr, table=""): out = "" print(topic + " " + attr + " " + str(comp)) - if hasAttr(comp.conf[B.SUBJECT_CONN], topic) and hasAttr(comp.conf[B.SUBJECT_CONN][topic], attr): - return getAttr(comp.conf[B.SUBJECT_CONN][topic], attr) - if len(table) > 1 and hasAttr(comp.conf[B.SUBJECT_ARTS][topic], table) \ - and hasAttr(comp.conf[B.SUBJECT_ARTS][topic][table], attr): - return getAttr(comp.conf[B.SUBJECT_ARTS][topic][table], attr) - if hasAttr(comp.conf[B.SUBJECT_ARTS], topic) and hasAttr(comp.conf[B.SUBJECT_ARTS][topic], attr): + if hasAttr(comp.conf[B.TOPIC_CONN], topic) and hasAttr(comp.conf[B.TOPIC_CONN][topic], attr): + return getAttr(comp.conf[B.TOPIC_CONN][topic], attr) + if len(table) > 1 and hasAttr(comp.conf[B.SUBJECT_ARTIFACT][topic], table) \ + and hasAttr(comp.conf[B.SUBJECT_ARTIFACT][topic][table], attr): + return getAttr(comp.conf[B.SUBJECT_ARTIFACT][topic][table], attr) + if hasAttr(comp.conf[B.SUBJECT_ARTIFACT], topic) and hasAttr(comp.conf[B.SUBJECT_ARTIFACT][topic], attr): print("attr " + attr + " vorhanden") - return getAttr(comp.conf[B.SUBJECT_ARTS][topic], attr) + return getAttr(comp.conf[B.SUBJECT_ARTIFACT][topic], attr) raise LookupError(topic + "." + attr + " is not set in comp " + comp.name) @@ -71,7 +71,7 @@ def getDbTool(job, comp, dbtype=""): if len(dbtype) < 3: dbtype = getCompAttr(comp, B.TOPIC_NODE_DB, B.ATTR_TYPE, "") toolname = "db" + dbtype + "_tool" - filepath = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM], "tools", toolname + ".py") + filepath = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_PROGRAM], "tools", toolname + ".py") # comp.m.debug(verify, "toolname "+filepath) if not os.path.exists(filepath): raise FileNotFoundError("dbi for tool " + toolname + " does not exist " + filepath) @@ -86,7 +86,7 @@ def getCliTool(job, comp): verify = int(job.getDebugLevel("db_tool")) clitype = getCompAttr(comp, B.TOPIC_NODE_CLI, B.ATTR_TYPE, "") toolname = "cli" + clitype + "_tool" - filepath = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM], "tools", toolname + ".py") + filepath = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_PROGRAM], "tools", toolname + ".py") # comp.m.debug(verify, "toolname "+filepath) if not os.path.exists(filepath): raise FileNotFoundError("file for tool " + toolname + " does not exist " + filepath) @@ -101,7 +101,7 @@ def getApiTool(job, comp): verify = int(job.getDebugLevel("db_tool")) apitype = getCompAttr(comp, B.TOPIC_NODE_API, B.ATTR_TYPE, "") toolname = "api" + apitype + "_tool" - filepath = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM], "tools", toolname + ".py") + filepath = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_PROGRAM], "tools", toolname + ".py") # comp.m.debug(verify, "toolname "+filepath) if not os.path.exists(filepath): raise FileNotFoundError("file for tool " + toolname + " does not exist " + filepath) @@ -121,7 +121,7 @@ def getFileTool(job, comp, filenode=""): else: filetype = getCompAttr(comp, B.TOPIC_NODE_FILE, B.ATTR_TYPE, "") toolname = "file" + filetype + "_fcts" - filepath = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM], "tools", toolname + ".py") + filepath = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_PROGRAM], "tools", toolname + ".py") # comp.m.debug(verify, "toolname "+filepath) if not os.path.exists(filepath): raise FileNotFoundError("file for tool " + toolname + " does not exist " + filepath) diff --git a/basic/user.py b/basic/user.py index 38ffd44..44e2bb9 100644 --- a/basic/user.py +++ b/basic/user.py @@ -34,7 +34,7 @@ class User(model.entity.Entity): """ self.job = job self.conf = {} - self.conf[B.SUBJECT_CONN] = self.getDbAttr(job) + self.conf[B.TOPIC_CONN] = self.getDbAttr(job) self.conf[B.DATA_NODE_DDL] = self.getDdl(job, ddl) self.m = job.m diff --git a/check_configuration.py b/check_configuration.py index b8f868b..e1a6f21 100644 --- a/check_configuration.py +++ b/check_configuration.py @@ -39,7 +39,7 @@ def checkComponent(job, componentName): :return: """ import model.component - configPath = config_tool.getExistingPath(job, [os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], componentName, "CONFIG")]) + configPath = config_tool.getExistingPath(job, [os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS], componentName, "CONFIG")]) configTree = file_tool.read_file_dict(job, configPath, job.m) for x in model.component.LIST_CP_SUBJECTS: if "conf" not in configTree: diff --git a/clean_workspace.py b/clean_workspace.py index f930d73..b4d74ac 100644 --- a/clean_workspace.py +++ b/clean_workspace.py @@ -46,7 +46,7 @@ def removeDebugFiles(job): """ job.m.logInfo("# # remove log-files # # #") limit = date_tool.getActdate(date_tool.F_LOG, LIMIT_DEBUG_FILES)[0:8] - path = job.conf[B.SUBJECT_PATH][B.ATTR_PATH_DEBUG] + path = job.conf[B.TOPIC_PATH][B.ATTR_PATH_DEBUG] cleanFolder(job, path, limit) path = os.path.join(B.HOME_PATH, "temp") cleanFolder(job, path, limit) diff --git a/job_dialog.py b/job_dialog.py index db8c930..262e53c 100644 --- a/job_dialog.py +++ b/job_dialog.py @@ -96,7 +96,7 @@ entities[DLG_TESTSUITE] = {} def readContext(job): for k in job.conf[B.SUBJECT_APPS]: appList.append(k) - path = job.conf[B.SUBJECT_PATH][B.ATTR_PATH_ENV] + path = job.conf[B.TOPIC_PATH][B.ATTR_PATH_ENV] if os.path.exists(path): for d in os.listdir(path): print ("-- "+d) @@ -105,7 +105,7 @@ def readContext(job): if d[0:1] == "_": continue envList.append(d) - path = job.conf[B.SUBJECT_PATH][B.ATTR_PATH_TDATA] + path = job.conf[B.TOPIC_PATH][B.ATTR_PATH_TDATA] if os.path.exists(path): for d in os.listdir(path): print("tdata path "+d) diff --git a/model/application.py b/model/application.py index ae13ee5..d9f0c04 100644 --- a/model/application.py +++ b/model/application.py @@ -71,7 +71,7 @@ def searchProjects(job, appl): and k not in appl[B.SUBJECT_APPS][getattr(job.par, B.PAR_APP)][B.SUBJECT_PROJECTS]: continue projects[k] = appl[B.SUBJECT_PROJECTS][k] - projects[k][B.SUBJECT_ENV] = [] + projects[k][B.SUBJECT_ENVIRONMENT] = [] else: job.conf[B.SUBJECT_PROJECTS] = appl[B.SUBJECT_PROJECTS] return projects @@ -84,7 +84,7 @@ def getEnvironments(job, projectList): :return: """ projects = {} - path = job.conf[B.SUBJECT_PATH][B.ATTR_PATH_ENV] + path = job.conf[B.TOPIC_PATH][B.ATTR_PATH_ENV] if os.path.exists(path): raise Exception("Umgebungsverzeichnis existiert nicht "+path) for envdir in os.listdir(path): @@ -103,9 +103,9 @@ def getEnvironments(job, projectList): if os.path.exists(pathname): doc = tools.file_tool.readFileDict(job, pathname, job.m) print(str(doc)) - for proj in doc[B.SUBJECT_ENV][B.CONF_NODE_GENERAL][B.SUBJECT_PROJECTS]: + for proj in doc[B.SUBJECT_ENVIRONMENT][B.CONF_NODE_GENERAL][B.SUBJECT_PROJECTS]: if proj in projectList: - projects[proj][B.SUBJECT_ENV].append(envdir) + projects[proj][B.SUBJECT_ENVIRONMENT].append(envdir) return projects def select_applications(job, projectList): @@ -124,7 +124,7 @@ def searchApplications(job, projectList, appl): if hasattr(job, "par") and hasattr(job.par, B.PAR_PROJ) and proj != getattr(job.par, B.PAR_PROJ): continue for app in appl[B.SUBJECT_APPS]: - if B.ATTR_APPS_PROJECT in appl[B.SUBJECT_APPS][app] and proj != appl[B.SUBJECT_APPS][app][B.ATTR_APPS_PROJECT]: + if B.SUBJECT_PROJECT in appl[B.SUBJECT_APPS][app] and proj != appl[B.SUBJECT_APPS][app][B.SUBJECT_PROJECT]: continue appList[app] = appl[B.SUBJECT_APPS][app] return appList @@ -141,8 +141,6 @@ def syncEnitities(job): :return: """ syncMethod = DEFAULT_SYNC - if B.SUBJECT_ENTITY in job.conf: - syncMethod = job.conf["entity"][TABLE_NAMES[0]]["storage"] if syncMethod.count("-") < 2: return fileTime = model.entity.VAL_ZERO_TIME @@ -150,7 +148,7 @@ def syncEnitities(job): # get git-commit if "git" in syncMethod: apppath = tools.config_tool.select_config_path(job, P.KEY_BASIC, B.SUBJECT_APPS, "") - repopath = apppath[len(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS]) + 1:] + repopath = apppath[len(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS]) + 1:] gitresult = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, repopath, 1) fileTime = gitresult[0]["date"] print(str(gitresult)) @@ -293,7 +291,7 @@ class Application_old(model.entity.Entity): def read_entity(self, job, app): apppath = tools.config_tool.select_config_path(job, P.KEY_BASIC, B.SUBJECT_APPS, "") - repopath = apppath[len(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS]) + 1:] + repopath = apppath[len(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS]) + 1:] gitresult = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, repopath, 1) applData = tools.config_tool.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS) # main object diff --git a/model/component.py b/model/component.py index 8cd0f02..c66b6a4 100644 --- a/model/component.py +++ b/model/component.py @@ -31,7 +31,7 @@ LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE] CP_SUBJECT_COMPS = "components" CP_SUBJECT_STEPS = "steps" CP_SUBJECT_TABLES = "tables" -CP_SUBJECT_ARTS = B.SUBJECT_ARTS +CP_SUBJECT_ARTS = B.SUBJECT_ARTIFACT LIST_CP_SUBJECTS = [CP_SUBJECT_COMPS, CP_SUBJECT_STEPS, CP_SUBJECT_TABLES, CP_SUBJECT_ARTS] REL_ATTR_TYPE = "relationtyp" @@ -54,7 +54,7 @@ def select_components(job, project, application): """ outList = [] appl = tools.config_tool.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS) - path = job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS] + path = job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS] for p in os.listdir(path): if p in ["catalog", "config", "test", "tools"]: continue @@ -91,7 +91,7 @@ class Component(model.entity.Entity): if application != "": app = model.factory.getApplication() return list(app.components.keys()) - path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS]) + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS]) outList = self.getDirlist(job, path, "csv") return outList diff --git a/model/entity.py b/model/entity.py index 4cad92c..8df95ee 100644 --- a/model/entity.py +++ b/model/entity.py @@ -135,7 +135,7 @@ class Entity: """ setattr(self, "m", job.m) config = {} - config[B.SUBJECT_CONN] = job.conf[B.TOPIC_NODE_DB] + config[B.TOPIC_CONN] = job.conf[B.TOPIC_NODE_DB] config[B.DATA_NODE_DDL] = {} for t in tables: ddl = tools.db_abstract.get_ddl(job, B.ATTR_INST_TESTSERVER, t) diff --git a/model/environment.py b/model/environment.py index 785865b..84ec18b 100644 --- a/model/environment.py +++ b/model/environment.py @@ -40,7 +40,7 @@ def select_environments(job, projectList): :return: """ environments = {} - path = job.conf[B.SUBJECT_PATH][B.ATTR_PATH_ENV] + path = job.conf[B.TOPIC_PATH][B.ATTR_PATH_ENV] if not os.path.exists(path): raise Exception("Umgebungsverzeichnis existiert nicht "+path) for envdir in os.listdir(path): @@ -51,11 +51,11 @@ def select_environments(job, projectList): try: pathname = tools.config_tool.select_config_path(job, P.KEY_TOOL, "conn", envdir) doc = tools.file_tool.read_file_dict(job, pathname, job.m) - for proj in doc[B.SUBJECT_ENV][B.CONF_NODE_GENERAL][B.SUBJECT_PROJECTS]: + for proj in doc[B.SUBJECT_ENVIRONMENT][B.CONF_NODE_GENERAL][B.SUBJECT_PROJECTS]: if proj in projectList: - environments[envdir] = doc[B.SUBJECT_ENV][B.CONF_NODE_GENERAL] + environments[envdir] = doc[B.SUBJECT_ENVIRONMENT][B.CONF_NODE_GENERAL] elif len(projectList) == 1 and projectList[0] == "ALL": - environments[envdir] = doc[B.SUBJECT_ENV][B.CONF_NODE_GENERAL] + environments[envdir] = doc[B.SUBJECT_ENVIRONMENT][B.CONF_NODE_GENERAL] except: continue return environments @@ -92,7 +92,7 @@ class Environment(model.entity.Entity): :param opt. args additional args :return: list of entity-names """ - path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_ENV]) + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_ENV]) outList = self.getDirlist(job, path, "") return outList diff --git a/model/project.py b/model/project.py index fdd8552..fc78d2e 100644 --- a/model/project.py +++ b/model/project.py @@ -139,7 +139,7 @@ class Project(model.entity.Entity): """ config = {} config[model.user.TABLE_NAME] = {} - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, P.VAL_USER, name + ".yml") for k in LIST_FIELDS: if getattr(self, k, "") == "" \ @@ -195,7 +195,7 @@ class Project(model.entity.Entity): :param name: single substring or list of name or dict of names with the keys as :return: """ - self.removeEntity(job, name, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, P.VAL_USER), "yml") + self.removeEntity(job, name, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, P.VAL_USER), "yml") def delete_entity(self, job, name, table): """ diff --git a/model/table.py b/model/table.py index ed0b5a8..15ce9de 100644 --- a/model/table.py +++ b/model/table.py @@ -12,6 +12,20 @@ import tools.config_tool import tools.file_tool import tools.git_tool +TABLE_NAME = "component" +""" system-name for this entity """ +FIELD_ID = "tbid" +FIELD_NAME = D.FIELD_NAME +FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION +FIELD_REFERENCE = B.SUBJECT_REFERENCE +FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES +FIELD_PROJECT = B.SUBJECT_PROJECT +FIELD_APPLICATION = B.SUBJECT_APP +LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE] +""" list of object-attributes """ + +LIST_SUBTABLES = [] + DEFAULT_FIELD = "" DEFAULT_TYPE = "string" DEFAULT_FORMAT = "vchar(256)" @@ -39,7 +53,7 @@ DEFAULTS = { def select_tables(job, project="", application="", component=""): outList = [] appl = tools.config_tool.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS) - path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], "catalog", "tables") + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS], "catalog", "tables") for p in os.listdir(path): if p[-4:] not in [".csv", ".yml", ".xml", "json"]: continue @@ -48,10 +62,11 @@ def select_tables(job, project="", application="", component=""): return outList class Table(model.entity.Entity): + tbid = 0 + name = "" project = "" application = "" component = "" - name = "" fieldnames = [] fielddef = {} @@ -67,8 +82,8 @@ class Table(model.entity.Entity): self.application = application if len(component) > 1: self.component = component - if len(name) > 1: - self.getEntity(job, name) + if len(name) > 1: + self.read_ddl(job, name) def get_schema(self, tableName="", tableObject=None): """ @@ -96,7 +111,7 @@ class Table(model.entity.Entity): if i % 2 == 1: continue if a[i] == "attr": - attr = {"attr":"attributes", "atype": D.TYPE_TEXT} + attr = {"attr":B.NODE_ATTRIBUTES, "atype": D.TYPE_TEXT} elif i+1 < len(a): attr = {"attr": a[i], "atype": a[i+1]} attrList.append(attr) @@ -112,12 +127,37 @@ class Table(model.entity.Entity): """ return sql + def read_unique_names(self, job, project, application, gran, args): + """ + reads the entity-names from file-storage + :param job: + :param opt. project: select-criteria if used and defined + :param opt. application: select-criteria if used and defined + :param opt. gran: granularity values testcase / testsuite / testplan + :param opt. args additional args + :return: list of entity-names + """ + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS], P.KEY_CATALOG, P.VAL_TABLES) + outList = self.getDirlist(job, path, "csv") + return outList + def read_entity(self, job, name): + config = self.getConfig(job, P.KEY_CATALOG, name, tools.config_tool.get_plain_filename(job, name)) + return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) + + def read_ddl(self, job, name): ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, self.component, name) self.fieldnames = [] fielddef = {} + if B.DATA_NODE_TABLES in ddl and name in ddl[B.DATA_NODE_TABLES]: + ddl = ddl[B.DATA_NODE_TABLES][name] + for k in ddl[B.DATA_NODE_DATA]: + if not isinstance(k, dict) \ + or D.DDL_FIELD not in k: + continue + ddl[k[D.DDL_FIELD]] = k for f in ddl: - if f in [B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS]: + if f in [B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_DATA]: continue field = {} self.fieldnames.append(f) diff --git a/model/testcase.py b/model/testcase.py index 71e0b72..0c51e6d 100644 --- a/model/testcase.py +++ b/model/testcase.py @@ -106,7 +106,7 @@ class Testcase(model.entity.Entity): """ if project == "": project = getattr(job.par, B.SUBJECT_PROJECT) - path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_TDATA], project, + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_TDATA], project, B.SUBJECT_TESTCASES) outList = self.getDirlist(job, path, "") return outList diff --git a/model/testsuite.py b/model/testsuite.py index beb6b20..c55c55c 100644 --- a/model/testsuite.py +++ b/model/testsuite.py @@ -71,7 +71,7 @@ class Testsuite(model.entity.Entity): :param opt. args additional args :return: list of entity-names """ - path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_TDATA], getattr(job.par, B.SUBJECT_PROJECT), + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_TDATA], getattr(job.par, B.SUBJECT_PROJECT), B.SUBJECT_TESTSUITES) outList = self.getDirlist(job, path, "") return outList diff --git a/model/user.py b/model/user.py index a01384b..b80005f 100644 --- a/model/user.py +++ b/model/user.py @@ -58,7 +58,7 @@ class User(model.entity.Entity): :return: list of entity-names """ outList = [] - path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_HOME], P.VAL_CONFIG, "user") + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_HOME], P.VAL_CONFIG, "user") for k in os.listdir(path): filename = tools.config_tool.get_plain_filename(job, k) if "default" == filename: @@ -152,7 +152,7 @@ class User(model.entity.Entity): """ config = {} config[model.user.TABLE_NAME] = {} - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, P.VAL_USER, name + ".yml") for k in LIST_FIELDS: if getattr(self, k, "") == "" \ @@ -208,7 +208,7 @@ class User(model.entity.Entity): :param name: single substring or list of name or dict of names with the keys as :return: """ - self.removeEntity(job, name, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, P.VAL_USER), "yml") + self.removeEntity(job, name, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, P.VAL_USER), "yml") def delete_entity(self, job, name, table): """ diff --git a/start_dialog.py b/start_dialog.py index 88fd55d..746ac64 100644 --- a/start_dialog.py +++ b/start_dialog.py @@ -121,6 +121,7 @@ def initDialog(job, args={}): args[J.MODEL_GRAN] = "" # """2 catalog = model.catalog.Catalog.getInstance() + setattr(job.par, B.SUBJECT_PROJECT, "TESTPROJ") programDef = catalog.getValue(job, basic.program.CTLG_NAME, args[B.PAR_PROGRAM], "") job.m.logTrace(verify, "programdefinition "+str(programDef)) if verbose: print("programdefinition "+args[B.PAR_PROGRAM]+" "+str(programDef)) diff --git a/test/test_02css.py b/test/test_02css.py index 5b92700..5922990 100644 --- a/test/test_02css.py +++ b/test/test_02css.py @@ -26,7 +26,7 @@ class MyTestCase(unittest.TestCase): job.par.setParameterArgs(job, args) # ------- inline --------------- job.conf.setConfig("tool.css.type", "inline") - job.conf.confs.get(B.SUBJECT_TOOL).get("css").get("typ") == "inline" + job.conf.get(B.TOPIC_TOOL).get("css").get("typ") == "inline" text = utils.css_tool.getInlineStyle(job, "diffFiles", "diffA") self.assertEqual(len(text), 37) self.assertEqual(("style" in text), True) diff --git a/test/test_03path.py b/test/test_03path.py index 831c002..d1644d3 100644 --- a/test/test_03path.py +++ b/test/test_03path.py @@ -22,10 +22,10 @@ class MyTestCase(unittest.TestCase): def setTestPaths(self, job): # here you can overwrite your workspace-configuration in order to get stable unittests - job.conf[B.SUBJECT_PATH][B.ATTR_PATH_HOME] = "home/unittest" - job.conf[B.SUBJECT_PATH][B.ATTR_PATH_TDATA] = "home/unittest/tdata" - job.conf[B.SUBJECT_PATH][B.ATTR_PATH_ENV] = "home/unittest/env" - job.conf[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV] = "home/unittest/archiv" + job.conf[B.TOPIC_PATH][B.ATTR_PATH_HOME] = "home/unittest" + job.conf[B.TOPIC_PATH][B.ATTR_PATH_TDATA] = "home/unittest/tdata" + job.conf[B.TOPIC_PATH][B.ATTR_PATH_ENV] = "home/unittest/env" + job.conf[B.TOPIC_PATH][B.ATTR_PATH_ARCHIV] = "home/unittest/archiv" pass def setPathConfig(self, pt): @@ -66,11 +66,11 @@ class MyTestCase(unittest.TestCase): self.setPathConfig(pt) # tests path = tools.path_tool.compose_path(job, P.P_ENVBASE, None) - self.assertIn(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_ENV], path) + self.assertIn(job.conf[B.TOPIC_PATH][B.ATTR_PATH_ENV], path) self.assertIn(getattr(job.par, B.PAR_ENV), path) cnttest += 2 path = tools.path_tool.compose_path(job, P.P_TCLOG, None) - self.assertIn(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV], path) + self.assertIn(job.conf[B.TOPIC_PATH][B.ATTR_PATH_ARCHIV], path) self.assertIn(getattr(job.par, B.PAR_TESTCASE), path) cnttest += 2 MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) diff --git a/test/test_04config.py b/test/test_04config.py index 0f626a8..ef1f0c1 100644 --- a/test/test_04config.py +++ b/test/test_04config.py @@ -39,23 +39,23 @@ class MyTestCase(unittest.TestCase): cnttest += 1 x = "path" r = tools.config_tool.select_config_path(job, P.KEY_TOOL, x) - self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], P.VAL_CONFIG), r) + self.assertIn(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], P.VAL_CONFIG), r) cnttest += 1 x = "conn" r = tools.config_tool.select_config_path(job, P.KEY_TOOL, x) - self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_ENV]), r) + self.assertIn(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_ENV]), r) cnttest += 1 self.assertRaises(Exception, tools.config_tool.select_config_path, (job, P.KEY_COMP, "TestX2")) # self.assertEqual(r, None) cnttest += 1 r = tools.config_tool.select_config_path(job, P.KEY_COMP, "testcrm") - self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], "testcrm", "CONFIG"), r) + self.assertIn(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], "testcrm", "CONFIG"), r) cnttest += 1 r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001") - self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], "TESTPROJ", B.SUBJECT_TESTCASES, "TC0001", "test"), r) + self.assertIn(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_TDATA], "TESTPROJ", B.SUBJECT_TESTCASES, "TC0001", "test"), r) cnttest += 1 r = tools.config_tool.select_config_path(job, P.KEY_TESTSUITE, "TST001") - self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], "TESTPROJ", B.SUBJECT_TESTSUITES, "TST001", "test"), r) + self.assertIn(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_TDATA], "TESTPROJ", B.SUBJECT_TESTSUITES, "TST001", "test"), r) @@ -75,20 +75,20 @@ class MyTestCase(unittest.TestCase): componentName = "testcm" confs = tools.config_tool.getConfig(job, "comp", componentName) conns = tools.conn_tool.getConnections(job, componentName) - self.assertEqual(confs["conf"][B.SUBJECT_INST][B.ATTR_INST_CNT], 1) - self.assertEqual(conns[0][B.SUBJECT_INST][B.ATTR_INST_CNT], 2) - self.assertNotIn(B.ATTR_INST_SGL, conns[0][B.SUBJECT_INST]) + self.assertEqual(confs["conf"][B.TOPIC_INST][B.ATTR_INST_CNT], 1) + self.assertEqual(conns[0][B.TOPIC_INST][B.ATTR_INST_CNT], 2) + self.assertNotIn(B.ATTR_INST_SGL, conns[0][B.TOPIC_INST]) confs["conf"] = tools.config_tool.mergeConn(job.m, confs["conf"], conns[0]) - self.assertEqual(confs["conf"][B.SUBJECT_INST][B.ATTR_INST_CNT], 2) + self.assertEqual(confs["conf"][B.TOPIC_INST][B.ATTR_INST_CNT], 2) cnttest += 1 # it overwrites - self.assertEqual(confs["conf"][B.SUBJECT_INST][B.ATTR_INST_SGL], "n") + self.assertEqual(confs["conf"][B.TOPIC_INST][B.ATTR_INST_SGL], "n") cnttest += 1 # it keep componentName = "testprddb" confs = tools.config_tool.getConfig(job, "comp", componentName) conns = tools.conn_tool.getConnections(job, componentName) - self.assertNotIn(B.ATTR_ARTS_TYPE, confs["conf"][B.SUBJECT_ARTS][B.TOPIC_NODE_DB]) + self.assertNotIn(B.ATTR_ARTS_TYPE, confs["conf"][B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB]) confs["conf"] = tools.config_tool.mergeConn(job.m, confs["conf"], conns[0]) - self.assertIn(B.ATTR_ARTS_TYPE, confs["conf"][B.SUBJECT_ARTS][B.TOPIC_NODE_DB]) + self.assertIn(B.ATTR_ARTS_TYPE, confs["conf"][B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB]) cnttest += 1 # new attribute MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) @@ -125,8 +125,8 @@ class MyTestCase(unittest.TestCase): plain = tools.config_tool.get_plain_filename(job, "testfall." + ext) self.assertEqual(plain, "testfall") for ext in tools.config_tool.CONFIG_FORMAT: - plain = tools.config_tool.get_plain_filename(job, os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM], - P.ATTR_PATH_TDATA, "testfall." + ext)) + plain = tools.config_tool.get_plain_filename(job, os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_PROGRAM], + P.ATTR_PATH_TDATA, "testfall." + ext)) self.assertEqual(plain, "testfall") def test_zzz(self): print(MyTestCase.mymsg) diff --git a/test/test_09git.py b/test/test_09git.py index 6482132..6e9bc93 100644 --- a/test/test_09git.py +++ b/test/test_09git.py @@ -50,7 +50,7 @@ class MyTestCase(unittest.TestCase): result = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, cnt=1) self.assertEqual(1, len(result)) apppath = tools.config_tool.select_config_path(job, P.KEY_BASIC, B.SUBJECT_APPS, "") - repopath = apppath[len(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS])+1:] + repopath = apppath[len(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS]) + 1:] result = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, repopath, 1) self.assertEqual(1, len(result)) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) diff --git a/test/test_12component.py b/test/test_12component.py index cc555f2..70ce961 100644 --- a/test/test_12component.py +++ b/test/test_12component.py @@ -107,16 +107,16 @@ class MyTestCase(unittest.TestCase): self.assertEqual(hasattr(c, "m"), True, "message-object must be") self.assertEqual(c.name, "testcm_01", "classname with number") # classname with number cnttest += 3 - self.assertEqual(c.conf[B.SUBJECT_INST][B.ATTR_INST_CNT], 2, "conn-attribute overwrites config-attribute") + self.assertEqual(c.conf[B.TOPIC_INST][B.ATTR_INST_CNT], 2, "conn-attribute overwrites config-attribute") cnttest += 1 # it overwrites - self.assertEqual(c.conf[B.SUBJECT_INST][B.ATTR_INST_SGL], "n", "without conn-attribute the config-attribute keeps") + self.assertEqual(c.conf[B.TOPIC_INST][B.ATTR_INST_SGL], "n", "without conn-attribute the config-attribute keeps") cnttest += 1 # it keep componentName = "testprddb" confs = tools.config_tool.getConfig(job, "comp", componentName) conns = tools.conn_tool.getConnections(job, componentName) c = cm.createInstance(componentName, None, confs, conns, 0) self.assertEqual(c.name, "testprddb") - self.assertIn(B.ATTR_DB_TYPE, c.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB], "conn-attribute creates missing config-attribute") + self.assertIn(B.ATTR_DB_TYPE, c.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB], "conn-attribute creates missing config-attribute") cnttest += 2 # new attributes MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) diff --git a/test/test_12toolhandling.py b/test/test_12toolhandling.py index 85d587b..3510579 100644 --- a/test/test_12toolhandling.py +++ b/test/test_12toolhandling.py @@ -34,31 +34,31 @@ class MyTestCase(unittest.TestCase): comp = basic.component.Component() comp.name = "testb" comp.conf = {} - comp.conf[B.SUBJECT_CONN] = {} - comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_CLI] = {} + 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_ARTS] = {} - comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_API] = {} - comp.conf[B.SUBJECT_CONN] = {} - comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB] = {} - comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_CLI] = {} - comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][B.ATTR_TYPE] = "mysql" - comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_CLI][B.ATTR_TYPE] = "ssh" + 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.SUBJECT_CONN][B.TOPIC_NODE_FILE] = {} - comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_FILE][B.ATTR_TYPE] = "xml" + comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_FILE] = {} + comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_FILE][B.ATTR_TYPE] = "xml" tool = basic.toolHandling.getFileTool(job, comp) self.assertRegex(str(type(tool)), 'filexml_tool.FileFcts') - comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][B.ATTR_TYPE] = "dxx" - comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_CLI][B.ATTR_TYPE] = "sxx" + 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) diff --git a/test/test_18i18n.py b/test/test_18i18n.py index 1d1ab28..bcaf004 100644 --- a/test/test_18i18n.py +++ b/test/test_18i18n.py @@ -61,7 +61,7 @@ class MyTestCase(unittest.TestCase): if verbose: print("RESULT "+res) self.assertEqual(res, "key doesnt exist in domain {}") cnttest += 1 - res = i18n.getText(f"{B.ATTR_APPS_PROJECT=}", job) + res = i18n.getText(f"{B.SUBJECT_PROJECT=}", job) if verbose: print("RESULT "+res) self.assertEqual(res, "project") cnttest += 1 diff --git a/test/test_25map.py b/test/test_25map.py index d936149..9dfecc5 100644 --- a/test/test_25map.py +++ b/test/test_25map.py @@ -9,18 +9,18 @@ import inspect import os import json import basic.program -import utils.path_tool -import utils.path_const as P -import utils.config_tool -import utils.data_const as D +import tools.path_tool +import tools.path_const as P +import tools.config_tool +import tools.data_const as D import basic.toolHandling import test.constants import basic.component import basic.constants as B -import utils.map_tool -import utils.file_tool +#import tools.map_tool +import tools.file_tool import test.testtools -import utils.tdata_tool +#import tools.tdata_tool HOME_PATH = test.constants.HOME_PATH @@ -42,13 +42,13 @@ class MyTestCase(unittest.TestCase): if actfunction not in TEST_FUNCTIONS: return job = test.testtools.getJob() - res = utils.map_tool.extractIds(job, "1") + res = tools.map_tool.extractIds(job, "1") self.assertEqual(res, ["1"]) - res = utils.map_tool.extractIds(job, "1, 2") + res = tools.map_tool.extractIds(job, "1, 2") self.assertEqual(res, "1,2".split(",")) - res = utils.map_tool.extractIds(job, "1-3") + res = tools.map_tool.extractIds(job, "1-3") self.assertEqual(res, "1,2,3".split(",")) - res = utils.map_tool.extractIds(job, "1, 3-6, 8") + res = tools.map_tool.extractIds(job, "1, 3-6, 8") self.assertEqual(res, "1,3,4,5,6,8".split(",")) cnttest += 4 MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) @@ -61,42 +61,42 @@ class MyTestCase(unittest.TestCase): if actfunction not in TEST_FUNCTIONS: return job = test.testtools.getJob() - path = utils.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "") - tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) + path = tools.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "") + tdata = tools.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) args = {} args[B.DATA_NODE_DATA] = tdata args[B.DATA_NODE_STEPS] = tdata[B.DATA_NODE_STEPS][0] - args[utils.map_tool.ACT_ID] = {} - args[utils.map_tool.ID_LIST] = {} + args[tools.map_tool.ACT_ID] = {} + args[tools.map_tool.ID_LIST] = {} ids = {} - res = utils.map_tool.getIds(job, args, "msgid={_steps._nr}") + res = tools.map_tool.getIds(job, args, "msgid={_steps._nr}") print(res) self.assertEqual(res[0], "1") - self.assertIn("msgid", args[utils.map_tool.ID_LIST]) + self.assertIn("msgid", args[tools.map_tool.ID_LIST]) cnttest += 1 - res = utils.map_tool.getIds(job, args, "sender={_data.person._sender(_steps._nr)}") + res = tools.map_tool.getIds(job, args, "sender={_data.person._sender(_steps._nr)}") print(res) self.assertEqual(res[0], "firma") args[B.DATA_NODE_STEPS] = tdata[B.DATA_NODE_STEPS][1] - res = utils.map_tool.getIds(job, args, "msgid={_steps._nr}") + res = tools.map_tool.getIds(job, args, "msgid={_steps._nr}") self.assertEqual(res[1], "2") - self.assertIn("msgid", args[utils.map_tool.ID_LIST]) + self.assertIn("msgid", args[tools.map_tool.ID_LIST]) cnttest += 1 - args[utils.map_tool.ACT_ID]["msgid"] = "1" - res = utils.map_tool.getIds(job, args, "posid={_data.product._nr,_pos(msgid)}") + args[tools.map_tool.ACT_ID]["msgid"] = "1" + res = tools.map_tool.getIds(job, args, "posid={_data.product._nr,_pos(msgid)}") self.assertEqual(res[0], ("1", "4")) self.assertEqual(res[1], ("1", "5")) cnttest += 1 compName = "testcrmdb" args[B.DATA_NODE_COMP] = test.testtools.getComp(job, compName) comp = args[B.DATA_NODE_COMP] - conf = utils.config_tool.getConfig(job, D.DDL_FILENAME, compName, "person") + conf = tools.config_tool.getConfig(job, D.DDL_FILENAME, compName, "person") comp.conf[B.DATA_NODE_DDL] = {} comp.conf[B.DATA_NODE_DDL]["person"] = conf - res = utils.map_tool.getIds(job, args, "fields={_comp.ddl.person}") + res = tools.map_tool.getIds(job, args, "fields={_comp.ddl.person}") print(res) - args[utils.map_tool.ACT_ID]["posid"] = ("1", "4") - res = utils.map_tool.getConditions(job, args, "{posid}") + args[tools.map_tool.ACT_ID]["posid"] = ("1", "4") + res = tools.map_tool.getConditions(job, args, "{posid}") print(res) self.assertEqual(res[0], ("1", "4")) #self.assertEqual(res[1], "4") @@ -111,15 +111,15 @@ class MyTestCase(unittest.TestCase): if actfunction not in TEST_FUNCTIONS: return job = test.testtools.getJob() - path = utils.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "") - tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) + path = tools.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "") + tdata = tools.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) condIds = [["1"]] args = {} args[B.DATA_NODE_DATA] = tdata - res = utils.map_tool.getFieldVal(job, args, "person", "_sender", condIds) + res = tools.map_tool.getFieldVal(job, args, "person", "_sender", condIds) print(res) condIds = [["1"], ["4"]] - res = utils.map_tool.getFieldVal(job, args, "product", "descript", condIds) + res = tools.map_tool.getFieldVal(job, args, "product", "descript", condIds) print(res) def test_05getValue(self): @@ -129,38 +129,38 @@ class MyTestCase(unittest.TestCase): if actfunction not in TEST_FUNCTIONS: return job = test.testtools.getJob() - path = utils.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "") - tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) + path = tools.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "") + tdata = tools.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) condIds = [["1"]] args = {} args[B.DATA_NODE_DATA] = tdata args[B.DATA_NODE_STEPS] = tdata[B.DATA_NODE_STEPS][0] - args[utils.map_tool.ACT_ID] = {} - args[utils.map_tool.ID_LIST] = {} - #res = utils.map_tool.getValue(job, args, "msgid={_steps._nr}") + args[tools.map_tool.ACT_ID] = {} + args[tools.map_tool.ID_LIST] = {} + #res = tools.map_tool.getValue(job, args, "msgid={_steps._nr}") #-print(res) #self.assertEqual(res, ['1']) - args[utils.map_tool.ACT_ID]["msgid"] = ['1'] - #res = utils.map_tool.getValue(job, args, "sender={_data.person._sender(msgid)}") + args[tools.map_tool.ACT_ID]["msgid"] = ['1'] + #res = tools.map_tool.getValue(job, args, "sender={_data.person._sender(msgid)}") #self.assertEqual(res, ["firma"]) #print(res) - print(args[utils.map_tool.ID_LIST]) - args[utils.map_tool.ACT_ID]["sender"] = "firma" - res = utils.map_tool.getValue(job, args, "{_catalog.sender.depart(sender)}") + print(args[tools.map_tool.ID_LIST]) + args[tools.map_tool.ACT_ID]["sender"] = "firma" + res = tools.map_tool.getValue(job, args, "{_catalog.sender.depart(sender)}") self.assertEqual(res, "main") - res = utils.map_tool.getValue(job, args, "{_steps.args.action}") + res = tools.map_tool.getValue(job, args, "{_steps.args.action}") print(res) - res = utils.map_tool.getValue(job, args, "{_par.tctime}") + res = tools.map_tool.getValue(job, args, "{_par.tctime}") print(res) - args[utils.map_tool.ACT_ID]["msgid"] = "1" - res = utils.map_tool.getValue(job, args, "{_data.person.famname(msgid)}") + args[tools.map_tool.ACT_ID]["msgid"] = "1" + res = tools.map_tool.getValue(job, args, "{_data.person.famname(msgid)}") print(res) self.assertEqual(res, "Brecht") - args[utils.map_tool.ACT_ID]["msgid"] = "1" + args[tools.map_tool.ACT_ID]["msgid"] = "1" # select row if field is missing - res = utils.map_tool.getValue(job, args, "{_data.person(msgid)}") + res = tools.map_tool.getValue(job, args, "{_data.person(msgid)}") print(res) - res = utils.map_tool.getValue(job, args, "hier ist ein Text") + res = tools.map_tool.getValue(job, args, "hier ist ein Text") print(res) # it is one row [{f_1: v_2, ...}] @@ -173,16 +173,16 @@ class MyTestCase(unittest.TestCase): return job = test.testtools.getJob() comp = test.testtools.getComp(job, "testrest") - path = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], "testrest", "mapping-rest.yml") - mapping = utils.file_tool.readFileDict(job, path, job.m) - path = utils.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "") - tdata = utils.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) - res = utils.map_tool.mapTdata(job, mapping, tdata, tdata[B.DATA_NODE_STEPS][1], comp) + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS], "testrest", "mapping-rest.yml") + mapping = tools.file_tool.readFileDict(job, path, job.m) + path = tools.config_tool.getConfigPath(job, P.KEY_TESTCASE, "TC0001", "") + tdata = tools.tdata_tool.getCsvSpec(job.m, job, path, D.CSV_SPECTYPE_DATA) + res = tools.map_tool.mapTdata(job, mapping, tdata, tdata[B.DATA_NODE_STEPS][1], comp) print(res) for format in ["xml", "yml", "json"]: - path = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_TDATA], "temp", "result-rest."+format) + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_TDATA], "temp", "result-rest." + format) print(path) - utils.file_tool.writeFileDict(job.m, job, path, res) + tools.file_tool.writeFileDict(job.m, job, path, res) doc = json.dumps(res, indent=0) print(doc) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) diff --git a/test/test_27table.py b/test/test_27table.py index e69de29..3420550 100644 --- a/test/test_27table.py +++ b/test/test_27table.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# --------------------------------------------------------------------------------------------------------- +# Author : Ulrich Carmesin +# Source : gitea.ucarmesin.de +# --------------------------------------------------------------------------------------------------------- +import unittest +import inspect +import test.testtools +import basic.constants as B +import test.constants as T +import model.table +import model.entity + +HOME_PATH = test.constants.HOME_PATH +PYTHON_CMD = "python" +TEST_FUNCTIONS = ["test_10getEntityNames", "test_11getEntities", "test_12getEntity", + "test_13writeEntity", "test_14insertEntity"] +TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity"] +PROGRAM_NAME = "clean_workspace" + +class MyTestCase(unittest.TestCase): + mymsg = "--------------------------------------------------------------" + + + def test_10getEntityNames(self): + global mymsg + global jobObject + actfunction = str(inspect.currentframe().f_code.co_name) + cnttest = 0 + if actfunction not in TEST_FUNCTIONS: + return + job = test.testtools.getJob() + table = model.table.Table(job, "TESTPROJ") + entityNames = table.read_unique_names(job, "", "", "", {}) + self.assertEquals(type(entityNames), list) + #entityNames = project.select_unique_names(job, "", "", "", {}) + #self.assertEquals(type(entityNames), list) + + def test_11getEntities(self): + global mymsg + global jobObject + actfunction = str(inspect.currentframe().f_code.co_name) + cnttest = 0 + if actfunction not in TEST_FUNCTIONS: + return + job = test.testtools.getJob() + table = model.table.Table(job, "TESTPROJ") + entityNames = [] + entityNames = table.get_entities(job, storage=model.entity.STORAGE_FILE) + self.assertEqual(type(entityNames), list) + #entityNames = table.get_entities(job, storage=model.entity.STORAGE_DB) + #self.assertEqual(type(entityNames), list) + + def test_12getEntity(self): + global mymsg + global jobObject + actfunction = str(inspect.currentframe().f_code.co_name) + cnttest = 0 + if actfunction not in TEST_FUNCTIONS: + return + job = test.testtools.getJob() + table = model.table.Table(job, "TESTPROJ") + name = "adress" + acttable = table.read_entity(job, name) + self.assertEqual(getattr(acttable, model.table.FIELD_NAME), name) + self.assertRaises(Exception, table.read_entity, job, "xyzxyz") + # + #actrelease = release.select_entity(job, name) + #self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name) + #self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"]) + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_31db.py b/test/test_31db.py index a4a8951..48c1a70 100644 --- a/test/test_31db.py +++ b/test/test_31db.py @@ -12,7 +12,7 @@ import basic.toolHandling import test.constants import basic.component import basic.constants as B -import utils.db_abstract +import tools.db_abstract import test.testtools import utils.config_tool import utils.data_const as D @@ -37,21 +37,21 @@ class MyTestCase(unittest.TestCase): if actfunction not in TEST_FUNCTIONS: return job = test.testtools.getJob() - obj = utils.db_abstract.parseConditions("family like !%utz%! and state = !+reg+!") + obj = tools.db_abstract.parseConditions("family like !%utz%! and state = !+reg+!") self.assertEqual(obj[0][3], "and") self.assertEqual(obj[0][1], "family") self.assertEqual(obj[1][3], "end") self.assertEqual(obj[1][1], "state") - obj = utils.db_abstract.parseConditions("family like !%utz%! or state = !+reg+!") + obj = tools.db_abstract.parseConditions("family like !%utz%! or state = !+reg+!") self.assertEqual(obj[0][3], "or") self.assertEqual(obj[0][1], "family") self.assertEqual(obj[1][3], "end") self.assertEqual(obj[1][1], "state") ddl = utils.config_tool.getConfig(job, D.DDL_FILENAME, "testb1", "lofts") - dbwhere = utils.db_abstract.parseSQLwhere("street like !%utz%! and state = !+reg+!", ddl["testb1"]["lofts"]) + dbwhere = tools.db_abstract.parseSQLwhere("street like !%utz%! and state = !+reg+!", ddl["testb1"]["lofts"]) self.assertIn("state", dbwhere) self.assertNotIn("family", dbwhere) - dbwhere = utils.db_abstract.parseSQLwhere("street like !%utz%! and state = !+reg+!", ddl["testb1"]["lofts"]) + dbwhere = tools.db_abstract.parseSQLwhere("street like !%utz%! and state = !+reg+!", ddl["testb1"]["lofts"]) self.assertIn("state", dbwhere) self.assertIn("street", dbwhere) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) @@ -74,34 +74,34 @@ class MyTestCase(unittest.TestCase): comp.conf = {} comp.conf[B.DATA_NODE_DDL] = {} comp.conf[B.DATA_NODE_DDL][table] = utils.config_tool.getConfig(job, D.DDL_FILENAME, comp.name, table) - 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" + comp.conf[B.SUBJECT_ARTIFACT] = {} + comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB] = {} + comp.conf[B.TOPIC_CONN] = {} + comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB] = {} + comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB][B.ATTR_TYPE] = "shive" tool = basic.toolHandling.getDbTool(job, comp) self.assertRegex(str(type(tool)), 'dbshive_tool.DbFcts') - attr = tool.getDbAttributes("xx") + attr = tool.getDbAttributes(job, "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") + comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "y" + attr = tool.getDbAttributes(job, "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") + comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "z" + attr = tool.getDbAttributes(job, "xx") self.assertRegex(attr[B.ATTR_DB_PARTITION], 'z') # sqls = comp.composeSqlClauses(job, "SELECT * FROM lofts") print(sqls) self.assertEqual(sqls["ALL"], "SELECT * FROM .lofts ORDER BY id") setattr(job.par, B.PAR_DB_WHERE, "street like !%utz%! and state = !+reg+!") - comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" + comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" sqls = comp.composeSqlClauses(job, "SELECT * FROM lofts") print(sqls) # dummy-comp does not correspond with any comp #self.assertIn("street", sqls["ALL"]) #assertEqual(("street" in sqls), True) #self.assertIn("state", sqls["ALL"]) setattr(job.par, B.PAR_DB_WHERE, "family like !%utz%! and state = !+reg+!") - comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" + comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB][B.ATTR_DB_PARTITION] = "+reg+" sqls = comp.composeSqlClauses(job, "SELECT * FROM lofts") print(sqls) self.assertIn("family", sqls["ALL"]) @@ -132,8 +132,8 @@ class MyTestCase(unittest.TestCase): if actfunction not in TEST_FUNCTIONS: return job = basic.program.Job("webflask", {}) - if B.TOPIC_NODE_DB in job.conf.confs: - dbtype = job.conf.confs[B.TOPIC_NODE_DB][B.ATTR_TYPE] + if B.TOPIC_NODE_DB in job.conf: + dbtype = job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE] userentity = basic.user.User(job) dbi = basic.toolHandling.getDbTool(job, userentity, dbtype) data = {} @@ -151,8 +151,8 @@ class MyTestCase(unittest.TestCase): if actfunction not in TEST_FUNCTIONS: return job = basic.program.Job("webflask", {}) - if B.TOPIC_NODE_DB in job.conf.confs: - dbtype = job.conf.confs[B.TOPIC_NODE_DB][B.ATTR_TYPE] + if B.TOPIC_NODE_DB in job.conf: + dbtype = job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE] userentity = basic.user.User(job) dbi = basic.toolHandling.getDbTool(job, userentity, dbtype) rows = dbi.selectRows("user", job) @@ -166,14 +166,14 @@ class MyTestCase(unittest.TestCase): if actfunction not in TEST_FUNCTIONS: return job = basic.program.Job("webflask", {}) - if B.TOPIC_NODE_DB in job.conf.confs: - dbtype = job.conf.confs[B.TOPIC_NODE_DB][B.ATTR_TYPE] + if B.TOPIC_NODE_DB in job.conf: + dbtype = job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE] userentity = basic.user.User(job) dbi = basic.toolHandling.getDbTool(job, userentity, dbtype) rows = dbi.selectRows("user", job, "WHERE username = \'alfons\'") cntpre = len(rows) print (str(rows)) - dbi.deleteRows("user", job, "WHERE username = \'alfons\'") + dbi.deleteRows(job, "user", "WHERE username = \'alfons\'") rows = dbi.selectRows("user", job, "WHERE username = \'alfons\'") print (str(rows)) cntpost = len(rows) diff --git a/test/test_31filecsv.py b/test/test_31filecsv.py index 86d6999..71e68e2 100644 --- a/test/test_31filecsv.py +++ b/test/test_31filecsv.py @@ -33,7 +33,7 @@ TEST_FUNCTIONS = [ "test_02isBlock", "test_03setSubtable", "test_06parseCsv", "test_11ddl", "test_12catalog", "test_13getCsvSpec_tree", "test_14getCsvSpec_key", "test_15getCsvSpec_conf", "test_16getCsvSpec_data" ] -TEST_FUNCTIONS = ["test_03setSubtable"] +TEST_FUNCTIONS = ["test_02isBlock"] PROGRAM_NAME = "clean_workspace" # with this variable you can switch prints on and off @@ -176,6 +176,7 @@ class MyTestCase(unittest.TestCase): cnttest = 0 if actfunction not in TEST_FUNCTIONS: return + #job = basic.program.SimpleJob(PROGRAM_NAME) job = test.testtools.getWorkspaceJob(PROGRAM_NAME) f = toolHandling.getFileTool(job, None, "csv") res = f.isBlock(job.m, job, "_variants", D.CSV_BLOCK_SUBTABLES, "status") diff --git a/test/test_43report.py b/test/test_43report.py index 382ec3f..d70c7f1 100644 --- a/test/test_43report.py +++ b/test/test_43report.py @@ -22,7 +22,7 @@ class MyTestCase(unittest.TestCase): def getReport(self, job): # job = test.testtools.getJob() report = utils.report_tool.Report(job) - archiv = job.conf[B.SUBJECT_PATH][B.ATTR_PATH_ARCHIV]+"/" + archiv = job.conf[B.TOPIC_PATH][B.ATTR_PATH_ARCHIV] + "/" i = 0 for m in M.MATCH_TYPES: report.setPaths("TC0001", "comp01", "arte01", m, archiv+"path0111"+str(i), archiv+"path0111"+str(i)+"02") diff --git a/test/test_90testserver.py b/test/test_90testserver.py index 92b5bc7..104d4b4 100644 --- a/test/test_90testserver.py +++ b/test/test_90testserver.py @@ -32,8 +32,8 @@ class MyTestCase(unittest.TestCase): self.assertIsNotNone(testserver) cnttest += 1 if B.TOPIC_NODE_DB in job.conf: - self.assertIn(B.TOPIC_NODE_DB, testserver.conf[B.SUBJECT_CONN]) - self.assertIn(B.ATTR_DB_DATABASE, testserver.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB]) + self.assertIn(B.TOPIC_NODE_DB, testserver.conf[B.TOPIC_CONN]) + self.assertIn(B.ATTR_DB_DATABASE, testserver.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB]) self.assertIn(B.DATA_NODE_DDL, testserver.conf) self.assertIn("application", testserver.conf[B.DATA_NODE_DDL]) MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) @@ -51,7 +51,7 @@ class MyTestCase(unittest.TestCase): else: job.conf[B.TOPIC_NODE_DB] = {} job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE] = "rel" - job.conf[B.TOPIC_NODE_DB][B.ATTR_DB_DATABASE] = "testserver" + job.conf[B.TOPIC_NODE_DB][B.ATTR_DB_DATABASE] = B.ATTR_INST_TESTSERVER self.job = job dbi = basic.toolHandling.getDbTool(job, self, "rel") # return "No DB in job-config" @@ -91,7 +91,7 @@ class MyTestCase(unittest.TestCase): if B.TOPIC_NODE_DB not in job.conf: job.conf[B.TOPIC_NODE_DB] = {} job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE] = "rel" - job.conf[B.TOPIC_NODE_DB][B.ATTR_DB_DATABASE] = "testserver" + job.conf[B.TOPIC_NODE_DB][B.ATTR_DB_DATABASE] = B.ATTR_INST_TESTSERVER self.job = job testserver = basic.Testserver.Testserver(job) for t in testserver.tables: diff --git a/test/testtools.py b/test/testtools.py index 81ac65c..83a19c7 100644 --- a/test/testtools.py +++ b/test/testtools.py @@ -22,7 +22,7 @@ path = "" # xample-DDL conf = { - B.SUBJECT_ARTS: { + B.SUBJECT_ARTIFACT: { B.TOPIC_NODE_DB: { B.ATTR_TYPE: "csv", "person": { @@ -108,5 +108,5 @@ def getComp(job, componentName=""): confs = tools.config_tool.getConfig(job, "comp", componentName) conns = tools.conn_tool.getConnections(job, componentName) comp.conf = confs["conf"] - comp.conf[B.SUBJECT_CONN] = conns[0] + comp.conf[B.TOPIC_CONN] = conns[0] return comp \ No newline at end of file diff --git a/test/unit.py b/test/unit.py index e69de29..1052da7 100644 --- a/test/unit.py +++ b/test/unit.py @@ -0,0 +1,6 @@ +import unittest + +class Unit(unittest.TestCase): + +if __name__ == '__main__': + unittest.main() diff --git a/tools/config_tool.py b/tools/config_tool.py index ec14c6e..d9d6816 100644 --- a/tools/config_tool.py +++ b/tools/config_tool.py @@ -61,13 +61,13 @@ def select_config_path(job, modul, name, subname=""): return getToolPath(job, name, subname) elif modul == P.KEY_COMP: for format in CONFIG_FORMAT: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], - P.VAL_CONFIG, P.KEY_COMP+"_" + name + "."+format) + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_HOME], + P.VAL_CONFIG, P.KEY_COMP +"_" + name + "." + format) if verify: job.debug(verify, "4 " + pathname) if os.path.exists(pathname): return pathname for format in CONFIG_FORMAT: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], basic.componentHandling.getComponentFolder(name), "CONFIG." + format) if verify: job.debug(verify, "5 " + pathname) if os.path.exists(pathname): @@ -99,22 +99,22 @@ def select_config_path(job, modul, name, subname=""): return pathname for format in CONFIG_FORMAT: if len(subname) > 1: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_RELEASE], - P.VAL_CONFIG, "basis."+format) + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_RELEASE], + P.VAL_CONFIG, "basis." + format) if verify: job.debug(verify, "9 " + pathname) if os.path.exists(pathname): return pathname for format in CONFIG_FORMAT: if len(subname) > 1: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_ENV], - P.VAL_CONFIG, "basis."+format) + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_ENV], + P.VAL_CONFIG, "basis." + format) if verify: job.debug(verify, "9 " + pathname) if os.path.exists(pathname): return pathname for format in CONFIG_FORMAT: if len(subname) > 1: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], - P.VAL_CONFIG, "basis."+format) + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_HOME], + P.VAL_CONFIG, "basis." + format) if verify: job.debug(verify, "9 " + pathname) if os.path.exists(pathname): return pathname @@ -127,19 +127,19 @@ def getToolPath(job, name, subname): envdir = job.par.environment else: envdir = "xxxxx" - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_ENV], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_ENV], envdir, P.VAL_CONFIG, P.KEY_TOOL + "_" + name)) if path is not None: return path - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], P.VAL_CONFIG, name)) if path is not None: return path - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, name)) if path is not None: return path - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_PROGRAM], P.VAL_TOOLS, P.VAL_CONFIG, name)) if path is not None: return path @@ -148,81 +148,81 @@ def getToolPath(job, name, subname): def getCompPath(job, name, subname, filename): # for example DATASTRUCURE or the table pathnames = [] - pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], + pathnames.append(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], basic.componentHandling.getComponentFolder(name), filename)) - pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], + pathnames.append(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], basic.componentHandling.getComponentFolder(subname), filename)) - pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], P.VAL_BASIC, filename)) - pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], P.VAL_BASIC, subname)) + pathnames.append(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_PROGRAM], P.VAL_BASIC, filename)) + pathnames.append(os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_PROGRAM], P.VAL_BASIC, subname)) configpath = getExistingPath(job, pathnames) if configpath is not None: return configpath if name == B.ATTR_INST_TESTSERVER: print(name) for format in CONFIG_FORMAT: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_PROGRAM], P.ATTR_PATH_MODEL, subname + "." + format) print(pathname) if os.path.exists(pathname): return pathname for format in CONFIG_FORMAT: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], basic.componentHandling.getComponentFolder(name), filename + "." + format) print(pathname) if os.path.exists(pathname): return pathname for format in CONFIG_FORMAT: if len(subname) > 1: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], basic.componentHandling.getComponentFolder(name), subname + "." + format) if os.path.exists(pathname): return pathname raise Exception(P.EXP_CONFIG_MISSING, filename + ", " + name) def getBasicPath(job, name): - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], P.VAL_CONFIG, name)) if path is not None: return path - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, name)) if path is not None: return path def getEnvironmentPath(job, name): - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_ENV], name, - P.VAL_CONFIG, B.SUBJECT_ENV)) + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_ENV], name, + P.VAL_CONFIG, B.SUBJECT_ENVIRONMENT)) if path is not None: return path def getTestPath(job, name, subdir, filename): for format in CONFIG_FORMAT: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], job.par.project, + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_TDATA], job.par.project, subdir, name, filename + "." + format) if os.path.exists(pathname): return pathname def getCatalogPath(job, name): if hasattr(job, "par") and hasattr(job.par, B.SUBJECT_PROJECT): - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_TDATA], getattr(job.par, B.SUBJECT_PROJECT), P.KEY_CATALOG, name)) if path is not None: return path - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_TDATA], P.KEY_CATALOG, name)) if path is not None: return path - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], P.KEY_CATALOG, name)) if path is not None: return path - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_COMPONENTS], P.KEY_CATALOG, P.VAL_TABLES, name)) if path is not None: return path - path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], + path = getExistingPath(job, os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_PROGRAM], P.KEY_CATALOG, name)) if path is not None: return path @@ -230,7 +230,7 @@ def getCatalogPath(job, name): def getUserPath(job, name): for ext in CONFIG_FORMAT: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, + pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_HOME], P.VAL_CONFIG, P.VAL_USER, name + "." + ext) if os.path.exists(pathname): return pathname @@ -253,9 +253,9 @@ def get_plain_filename(job, path): def getConfValue(attribute, comp): if attribute == B.ATTR_CONN_DBTYPE: - if not hasAttr(comp.conf[B.SUBJECT_CONN], "dbtype"): - if hasAttr(comp.conf[B.SUBJECT_CONN], "types") and hasAttr(comp.conf[B.SUBJECT_CONN]["types"], "dbtype"): - dbtype = comp.conf[B.SUBJECT_CONN]["types"]["dbtype"] + if not hasAttr(comp.conf[B.TOPIC_CONN], "dbtype"): + if hasAttr(comp.conf[B.TOPIC_CONN], "types") and hasAttr(comp.conf[B.TOPIC_CONN]["types"], "dbtype"): + dbtype = comp.conf[B.TOPIC_CONN]["types"]["dbtype"] else: raise LookupError("dbtype is not set in comp " + comp.name) else: @@ -341,29 +341,29 @@ def getAttributeList(comp, path, job): a = path.split(".") artType = a[0] artName = a[1] - if B.SUBJECT_CONN not in comp.conf: + if B.TOPIC_CONN not in comp.conf: raise Exception ("Environment is not configured") - if artType in comp.conf[B.SUBJECT_CONN]: - if artName in comp.conf[B.SUBJECT_CONN][artType]: - for attr, val in comp.conf[B.SUBJECT_CONN][artType][artName].items(): + if artType in comp.conf[B.TOPIC_CONN]: + if artName in comp.conf[B.TOPIC_CONN][artType]: + for attr, val in comp.conf[B.TOPIC_CONN][artType][artName].items(): if attr not in B.LIST_ATTR[artType]: continue attrList[attr] = val - for attr, val in comp.conf[B.SUBJECT_CONN][artType].items(): + for attr, val in comp.conf[B.TOPIC_CONN][artType].items(): if attr not in B.LIST_ATTR[artType]: continue if attr in attrList: continue attrList[attr] = val - if artType in comp.conf[B.SUBJECT_ARTS]: - if artName in comp.conf[B.SUBJECT_ARTS][artType]: - for attr, val in comp.conf[B.SUBJECT_ARTS][artType][artName].items(): + if artType in comp.conf[B.SUBJECT_ARTIFACT]: + if artName in comp.conf[B.SUBJECT_ARTIFACT][artType]: + for attr, val in comp.conf[B.SUBJECT_ARTIFACT][artType][artName].items(): if attr not in B.LIST_ATTR[artType]: continue if attr in attrList: continue attrList[attr] = val - for attr, val in comp.conf[B.SUBJECT_ARTS][artType].items(): + for attr, val in comp.conf[B.SUBJECT_ARTIFACT][artType].items(): if attr not in B.LIST_ATTR[artType]: continue if attr in attrList: @@ -381,12 +381,12 @@ def mergeConn(msg, conf, conn): :return: """ - if B.SUBJECT_INST not in conf: - conf[B.SUBJECT_INST] = {} - for a in conn[B.SUBJECT_INST]: - conf[B.SUBJECT_INST][a] = conn[B.SUBJECT_INST][a] + if B.TOPIC_INST not in conf: + conf[B.TOPIC_INST] = {} + for a in conn[B.TOPIC_INST]: + conf[B.TOPIC_INST][a] = conn[B.TOPIC_INST][a] for topic in [B.TOPIC_NODE_DB, B.TOPIC_NODE_CLI, B.TOPIC_NODE_API, B.TOPIC_NODE_FILE]: - if topic not in conf[B.SUBJECT_ARTS]: + if topic not in conf[B.SUBJECT_ARTIFACT]: continue if topic == B.TOPIC_NODE_DB: list = B.LIST_DB_ATTR @@ -396,26 +396,26 @@ def mergeConn(msg, conf, conn): list = B.LIST_API_ATTR if topic == B.TOPIC_NODE_FILE: list = B.LIST_FILE_ATTR - for a in conf[B.SUBJECT_ARTS][topic]: + for a in conf[B.SUBJECT_ARTIFACT][topic]: if topic not in conn: continue if a in list: if a in conn[topic]: - conf[B.SUBJECT_ARTS][topic][a] = conn[topic][a] + conf[B.SUBJECT_ARTIFACT][topic][a] = conn[topic][a] else: - for b in conf[B.SUBJECT_ARTS][topic][a]: + for b in conf[B.SUBJECT_ARTIFACT][topic][a]: if b not in list: msg.logError("not-topic-attribute in topic-connection: "+topic+", "+b) continue if a not in conn[topic]: continue if b in conn[topic][a]: - conf[B.SUBJECT_ARTS][topic][a][b] = conn[topic][a][b] + conf[B.SUBJECT_ARTIFACT][topic][a][b] = conn[topic][a][b] for a in list: if topic not in conn: break if topic not in conn: continue if a in conn[topic]: - conf[B.SUBJECT_ARTS][topic][a] = conn[topic][a] + conf[B.SUBJECT_ARTIFACT][topic][a] = conn[topic][a] return conf \ No newline at end of file diff --git a/tools/conn_tool.py b/tools/conn_tool.py index acd4c2f..541b8c4 100644 --- a/tools/conn_tool.py +++ b/tools/conn_tool.py @@ -13,8 +13,8 @@ def getConnection(job, comp, nr): #job = basic.program.Job.getInstance() verify = job.getDebugLevel("conn_tool") conn = {} - if job.conf.get(B.SUBJECT_TOOL).get("connsrc") == D.DFILE_TYPE_YML: - conn = tools.config_tool.getConfig(job, "tool", B.SUBJECT_CONN) + if job.conf.get(B.TOPIC_TOOL).get("connsrc") == D.DFILE_TYPE_YML: + conn = tools.config_tool.getConfig(job, "tool", B.TOPIC_CONN) xtypes = None if ("types" in conn["env"][comp]): xtypes = conn["env"][comp]["types"] @@ -53,29 +53,29 @@ def getConnections(job, comp): # # select # pass - conn = tools.config_tool.getConfig(job, "tool", B.SUBJECT_CONN) - if not comp in conn[B.SUBJECT_ENV]: + conn = tools.config_tool.getConfig(job, "tool", B.TOPIC_CONN) + if not comp in conn[B.SUBJECT_ENVIRONMENT]: job.m.setFatal("Conn-Tool: Comp not configured " + comp) attr = {} - if B.CONF_NODE_GENERAL in conn[B.SUBJECT_ENV]: - for a in conn[B.SUBJECT_ENV][B.CONF_NODE_GENERAL]: - attr[a] = conn[B.SUBJECT_ENV][B.CONF_NODE_GENERAL] - for a in conn[B.SUBJECT_ENV][comp]: - if "inst" in a and a != B.SUBJECT_INST: + if B.CONF_NODE_GENERAL in conn[B.SUBJECT_ENVIRONMENT]: + for a in conn[B.SUBJECT_ENVIRONMENT][B.CONF_NODE_GENERAL]: + attr[a] = conn[B.SUBJECT_ENVIRONMENT][B.CONF_NODE_GENERAL] + for a in conn[B.SUBJECT_ENVIRONMENT][comp]: + if "inst" in a and a != B.TOPIC_INST: continue - attr[a] = conn[B.SUBJECT_ENV][comp][a] + attr[a] = conn[B.SUBJECT_ENVIRONMENT][comp][a] #if ("types" in conn["env"][comp]): # xtypes = conn["env"][comp]["types"] - for i in range(conn[B.SUBJECT_ENV][comp][B.SUBJECT_INST][B.ATTR_INST_CNT]): + for i in range(conn[B.SUBJECT_ENVIRONMENT][comp][B.TOPIC_INST][B.ATTR_INST_CNT]): #print("range " + str(i + 1)) instnr = "inst" + str(i + 1) #if (xtypes is not None): # conn["env"][comp][instnr]["types"] = xtypes for a in attr: - if a in conn[B.SUBJECT_ENV][comp][instnr]: + if a in conn[B.SUBJECT_ENVIRONMENT][comp][instnr]: continue # dont overwrite an instance-specific value - conn[B.SUBJECT_ENV][comp][instnr][a] = attr[a] - conns.append(conn[B.SUBJECT_ENV][comp][instnr]) + conn[B.SUBJECT_ENVIRONMENT][comp][instnr][a] = attr[a] + conns.append(conn[B.SUBJECT_ENVIRONMENT][comp][instnr]) return conns diff --git a/tools/db_abstract.py b/tools/db_abstract.py index 8e4c5de..ce18876 100644 --- a/tools/db_abstract.py +++ b/tools/db_abstract.py @@ -107,24 +107,24 @@ def getDbAttributes(job, comp, table): if (attr in job.conf[B.TOPIC_NODE_DB]): out[attr] = job.conf[B.TOPIC_NODE_DB][attr] else: - if (B.SUBJECT_ARTS in comp.conf and table in comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB]) \ - and (attr in comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][table]): - out[attr] = comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][table][attr] + if (B.SUBJECT_ARTIFACT in comp.conf and table in comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB]) \ + and (attr in comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB][table]): + out[attr] = comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB][table][attr] print("a " + attr + " " + out[attr]) - elif (B.SUBJECT_ARTS in comp.conf and attr in comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB]): - out[attr] = comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB][attr] + elif (B.SUBJECT_ARTIFACT in comp.conf and attr in comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB]): + out[attr] = comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB][attr] print("b " + attr + " " + out[attr]) - elif (B.TOPIC_NODE_DB in comp.conf[B.SUBJECT_CONN]) \ - and (table in comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB]) \ - and (attr in comp.conf[B.SUBJECT_CONN][table][B.TOPIC_NODE_DB]): - out[attr] = comp.conf[B.SUBJECT_CONN][table][B.TOPIC_NODE_DB][attr] + elif (B.TOPIC_NODE_DB in comp.conf[B.TOPIC_CONN]) \ + and (table in comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB]) \ + and (attr in comp.conf[B.TOPIC_CONN][table][B.TOPIC_NODE_DB]): + out[attr] = comp.conf[B.TOPIC_CONN][table][B.TOPIC_NODE_DB][attr] print("c " + attr + " " + out[attr]) - elif (B.TOPIC_NODE_DB in comp.conf[B.SUBJECT_CONN]) \ - and (attr in comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB]): - out[attr] = comp.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][attr] + elif (B.TOPIC_NODE_DB in comp.conf[B.TOPIC_CONN]) \ + and (attr in comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB]): + out[attr] = comp.conf[B.TOPIC_CONN][B.TOPIC_NODE_DB][attr] print("d " + attr + " " + out[attr]) - elif (attr in comp.conf[B.SUBJECT_CONN]): - out[attr] = comp.conf[B.SUBJECT_CONN][attr] + elif (attr in comp.conf[B.TOPIC_CONN]): + out[attr] = comp.conf[B.TOPIC_CONN][attr] print("e " + attr + " " + out[attr]) else: print("f " + attr + " " + out[attr]) @@ -301,7 +301,7 @@ def isCompRow(comp, row): """ checks if the table in data relates to the component """ print("isCompRow "+comp.name+" "+str(row)) if comp.name in row[B.ATTR_DATA_COMP] \ - and row[B.ATTR_DATA_COMP][comp.name] in comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_DB]: + and row[B.ATTR_DATA_COMP][comp.name] in comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_DB]: return True return False diff --git a/tools/file_abstract.py b/tools/file_abstract.py index 2316a0b..82583e4 100644 --- a/tools/file_abstract.py +++ b/tools/file_abstract.py @@ -79,7 +79,7 @@ class FileFcts(): archivpath = "" filename = step.args["filename"] txt = "" - for o in self.comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_FILE]: + for o in self.comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_FILE]: if o["name"] != filename: continue mapping = o["mapping"] @@ -94,7 +94,7 @@ class FileFcts(): technique = step.args["technique"] archivpath = os.path.join(tools.path_tool.compose_path(job, "{tcresult}/request", self.comp), filename) if technique == "cli": - for o in self.comp.conf[B.SUBJECT_ARTS][B.TOPIC_NODE_FILE]: + for o in self.comp.conf[B.SUBJECT_ARTIFACT][B.TOPIC_NODE_FILE]: if o["name"] != filename: continue envpath = o["envpath"] diff --git a/tools/filecsv_fcts.py b/tools/filecsv_fcts.py index 5e307d5..598a430 100644 --- a/tools/filecsv_fcts.py +++ b/tools/filecsv_fcts.py @@ -12,7 +12,8 @@ import basic.constants as B import tools.data_const as D import tools.file_tool from basic import toolHandling - +import traceback +import tools.data_tool class FileFcts(tools.file_abstract.FileFcts): @@ -54,10 +55,10 @@ class FileFcts(tools.file_abstract.FileFcts): """ try: print("isBlock "+field + " , " + block + " , " + status) - blockPur = self.getPurValue(block) + blockPur = tools.data_tool.getPurKeyword(block) a = field.split(":") - keyPur = self.getPurValue(a[0]) - statusPur = self.getPurValue(status) + keyPur = tools.data_tool.getPurKeyword(a[0]) + statusPur = tools.data_tool.getPurKeyword(status) if statusPur+"s-" in keyPur: keyPur = keyPur[keyPur.find("-")+1:] print("isBlock "+a[0] + "=" + keyPur +" , " + blockPur + " , " + status) @@ -80,7 +81,8 @@ class FileFcts(tools.file_abstract.FileFcts): if block == D.CSV_BLOCK_ATTR and len(a) == 1 and field[0:1] == "_": return True return False - except: + except Exception as e: + print(traceback.format_exc()) print("isBlock "+field + "=?" + block) def parseCsv(self, msg, job, lines, ttype=""): diff --git a/tools/git_tool.py b/tools/git_tool.py index 3b4842c..aea46cc 100644 --- a/tools/git_tool.py +++ b/tools/git_tool.py @@ -35,8 +35,8 @@ def execCmd(job, repo, cmd): cdpath = "" if os.path.isdir(repo): cdpath = repo - elif repo in job.conf[B.SUBJECT_PATH]: - cdpath = job.conf[B.SUBJECT_PATH][repo] + elif repo in job.conf[B.TOPIC_PATH]: + cdpath = job.conf[B.TOPIC_PATH][repo] else: raise Exception(T.EXP_PATH_MISSING, repo) print("execCmd on " + cdpath + ": " + cmd) @@ -113,11 +113,11 @@ def updateRemote(job, local, repo): os.chdir(job.home) def gitPull(job, repo): - if "git" not in job.conf[B.SUBJECT_TOOL] or repo not in job.conf[B.SUBJECT_TOOL]["git"]: + if "git" not in job.conf[B.TOPIC_TOOL] or repo not in job.conf[B.TOPIC_TOOL]["git"]: raise Exception(T.EXP_CONFIG_MISSING, "tool.git."+repo) #print(str(job.conf[B.SUBJECT_TOOL]["git"][repo])) - master = job.conf[B.SUBJECT_TOOL]["git"][repo]["master"] - remote = job.conf[B.SUBJECT_TOOL]["git"][repo]["remote"] + master = job.conf[B.TOPIC_TOOL]["git"][repo]["master"] + remote = job.conf[B.TOPIC_TOOL]["git"][repo]["remote"] text = execCmd(job, repo, "git status") if "Commit vor" in text: print("Das Repository "+repo+" bitte zuerst pushen \n") diff --git a/tools/job_tool.py b/tools/job_tool.py index 4f5308a..fed570e 100644 --- a/tools/job_tool.py +++ b/tools/job_tool.py @@ -88,7 +88,7 @@ def getUserProject(job=None): return "TESTPROJ" def getActChildPath(job): - return os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_DEBUG], job.username+".json") + return os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_DEBUG], job.username + ".json") def read_child_args(job): path = getActChildPath(job) diff --git a/tools/path_const.py b/tools/path_const.py index f33bdd6..373492a 100644 --- a/tools/path_const.py +++ b/tools/path_const.py @@ -23,7 +23,7 @@ KEY_COMP = "comp" """ keyword for individual component """ KEY_TOOL = "tool" """ keyword for technical tools """ -KEY_ENV = B.SUBJECT_ENV +KEY_ENV = B.SUBJECT_ENVIRONMENT """ keyword for environment """ VAL_TOOLS = "tools" """ subdir for any technical tools """ diff --git a/tools/path_tool.py b/tools/path_tool.py index 6e629d3..fc9e0e4 100644 --- a/tools/path_tool.py +++ b/tools/path_tool.py @@ -50,7 +50,7 @@ def getBasisConfigPath(): def getActualJsonPath(job): username = getpass.getuser() - path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_DEBUG], username+"Job.json") + path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_DEBUG], username + "Job.json") return path diff --git a/tools/value_tool.py b/tools/value_tool.py index 024e9c5..a2db04a 100644 --- a/tools/value_tool.py +++ b/tools/value_tool.py @@ -64,7 +64,7 @@ def get_key_value(job, key, comp=None): val = job.getParameter(a[2]) return val elif DOM_CONF == k: - val = job.conf[B.SUBJECT_PATH][a[2]] + val = job.conf[B.TOPIC_PATH][a[2]] if verify: job.debug(verify, val) return val elif len(a) == 2: