# # # ---------------------------------------------------------- """ This program is created for the business-test on the level of unit testing. On this level there is an intensive test-set up to a carthesian product possible. The test-specification is written in a yaml-config in the data-directory. workflow: 1. generate test-cases with all inputs into a csv-file of the spec-yaml 2. run the csv-file and collect all results into a new result-csv-file with all inputs and outputs 3. check the result-csv-file and declare it as a target-results OR instead 2 and 3 on test-first-strategy: 3. create manually the target-result with your inputs and the target system-outputs 4. run and compare the actual-result with the target-result 5. at the end you get an xls-sheet like your result-csv-file but additionally with comparsion-result as detailed result and the only counts of passed and failed tests as minimum-result which can be inserted into management-tools """ # Press the green button in the gutter to run the script. import importlib import os, glob import io import sys import basic.program import basic.constants as B import tools.job_tool as job_tool import model.catalog import tools.job_const as J PROGRAM_NAME = "start_dialog" verbose = False def startPyJob(job): # for debugging write setattr(job.par, "tool", "job_tool") # check if an actual job is stored childArgs = job_tool.read_child_args(job) if childArgs is None: childArgs = initDialog(job) else: childDialog(job) pass def getChoice(job, choiselist, description): """ to choise one of the list or exit the program :param job: :param choiselist: :param description: :return: """ index = 0 if isinstance(choiselist, dict): choiselist = list(choiselist.keys()) if len(choiselist) == 0: raise Exception("Keine Auswahl zu: "+description) if len(choiselist) == 1: return choiselist[0] print("+------------- "+description+" ----------") print('| | {:2d} : {:60s}'.format(0, "exit")) for k in choiselist: index += 1 print('| | {:2d} : {:60s}'.format(index, k)) print("+-----------------------------------------------") choice = input("Auswahl 1-" + str(index) + ": ") if verbose: print("auswahl "+str(choice)) if not choice.isnumeric(): print("FEHLER Fehleingabe "+choice) getChoice(job, choiselist, description) elif int(choice) < 1: job.stopJob(0) exit(0) elif int(choice) > index: print("FEHLER Fehleingabe "+choice) getChoice(job, choiselist, description) else: if verbose: print("treffer "+str(choiselist)) return choiselist[int(choice) - 1] def initDialog(job, args={}): """ dialog to initialize a child-process :param job: :return: """ # which process verify = job.m.getLogLevel("job_tool") if "proc" not in args: args["proc"] = getChoice(job, J.LIST_PROC, "Welchen Prozess starten") args[J.MODEL_GRAN] = "" args[B.PAR_USER] = job_tool.getUser() args[B.PAR_PROJ] = job_tool.getUserProject() args[B.PAR_STEP] = "" job.m.logTrace(verify, args["proc"]) # """ if args["proc"] == J.PROC_TP_EXECUTION: #args[J.MODEL_GRAN] = B.PAR_TESTPLAN args[B.PAR_STEP] = "1" args[B.PAR_PROGRAM] = J.PROG_TEST_EXECUTER elif args["proc"] in [J.PROC_TS_STEPWISE, J.PROC_TS_EXECUTION]: #args[J.MODEL_GRAN] = B.PAR_TESTSUITE args[B.PAR_STEP] = "1" if args["proc"] == J.PROC_TS_EXECUTION: args[B.PAR_PROGRAM] = J.PROG_TEST_EXECUTER else: args[B.PAR_PROGRAM] = J.PROG_TS_INIT elif args["proc"] in [J.PROC_TC_STEPWISE, J.PROC_TC_EXECUTION]: #args[J.MODEL_GRAN] = B.PAR_TESTCASE args[B.PAR_STEP] = "1" if args["proc"] == J.PROC_TC_EXECUTION: args[B.PAR_PROGRAM] = J.PROG_TEST_EXECUTER else: args[B.PAR_PROGRAM] = J.PROG_TC_INIT elif args["proc"] == J.PROC_REDO_EXECUTION: args[B.PAR_PROGRAM] = getChoice(job, J.LIST_TS_PROGS + J.LIST_TC_PROGS, "Welches Programm starten") elif args["proc"] == J.PROC_SINGLE_JOB: args[B.PAR_PROGRAM] = getChoice(job, J.LIST_SERVICE_PROG, "Welches Programm starten") else: args[J.MODEL_GRAN] = "" args[J.MODEL_GRAN] = "" # """2 catalog = model.catalog.Catalog.getInstance() 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)) for p in programDef[basic.program.CTLG_PARDEF]: job.m.logTrace(verify, "progCtlog "+p+":") job.m.logTrace(verify, args) if verbose: print(" "+p+" "+str(args)) if p in args and len(args[p]) > 0: if verbose: print("arg: " + p+" "+args[p]) job.m.logDebug(verify, "progArg "+p+" ist "+args[p]) elif programDef[basic.program.CTLG_PARDEF][p] == "args": description = "" job.m.logDebug(verify, "to select "+p) if p == B.PAR_GRAN: description = J.CHOICE_GRAN choiceList = J.LIST_GRAN elif p == B.PAR_APP: description = J.CHOICE_APP choiceList = job_tool.select_application(job, programDef, args[B.PAR_PROJ]) elif p == J.ARG_TESTELEM: if verbose: print("testelem "+args[B.PAR_GRAN]) if args[B.PAR_GRAN] in [J.GRAN_TP, B.PAR_TESTPLAN]: description = J.CHOICE_TP choiceList = job_tool.select_testplan(job, programDef, args) p = B.PAR_TESTPLAN elif args[B.PAR_GRAN] in [J.GRAN_TS, B.PAR_TESTSUITE]: description = J.CHOICE_TS choiceList = job_tool.select_testsuite(job, programDef, args) p = B.PAR_TESTSUITE elif args[B.PAR_GRAN] in [J.GRAN_TC, B.PAR_TESTCASE]: description = J.CHOICE_TC choiceList = job_tool.select_testcase(job, programDef, args) p = B.PAR_TESTCASE else: raise Exception("unknown testgranularity "+args[B.PAR_GRAN]) elif p == B.PAR_ENV: description = J.CHOICE_ENV choiceList = job_tool.select_environment(job, programDef, args[B.PAR_PROJ]) elif p in [B.PAR_TESTPLAN, B.PAR_TESTSUITE, B.PAR_TESTCASE]: if args["proc"] == J.PROC_REDO_EXECUTION: description = J.CHOICE_ARCHIV choiceList = job_tool.select_archiv(job, programDef, args[J.MODEL_GRAN], args[B.PAR_APP]) else: args[B.PAR_STEP] = "1" description = J.CHOICE_SPEC choiceList = job_tool.select_spec(job, programDef, args[J.MODEL_GRAN], args) elif p in [B.PAR_TSTIME, B.PAR_TCTIME] and args["proc"] in [J.PROC_REDO_EXECUTION]: description = J.CHOICE_TIME choiceList = job_tool.select_testtime(job, programDef, args[J.MODEL_GRAN], args) elif p == B.PAR_VAR: description = J.CHOICE_VARIANT choiceList = job_tool.select_variant(job, programDef, args[J.MODEL_GRAN], args) else: continue if choiceList is None: job.m.logError(verify, "choiceList in None "+p) args[p] = getChoice(job, choiceList, description) else: args[p] = programDef[basic.program.CTLG_PARDEF][p] job.m.logDebug(verify, "p "+p+" jetzt ") job.m.logDebug(verify, args[p]) job.m.logDebug(verify, args) job_tool.write_child_args(job, args) job_tool.start_child_process(job, args) childDialog(job) def childDialog(job): """ dialog to manage the child-process :param job: :return: """ args = job_tool.read_child_args(job) print("+-----------------------------------------------") for p in args: if p in ["proc"]: continue if len(args[p]) < 1: continue print('+ {:12s} : {:60s}'.format(p, args[p])) print("+-----------------------------------------------") initDialog(job) if __name__ == '__main__': job = basic.program.Job(PROGRAM_NAME) # TODO to move to job_tool args = {} if isinstance(job.programDef[basic.program.CTLG_PARDEF], dict): for p in job.programDef[basic.program.CTLG_PARDEF]: args[p] = job.programDef[basic.program.CTLG_PARDEF][p] job.setParameter(args) job.startJob() startPyJob(job) job.stopJob(0)