CLIConfigurator.set_project_id(using_pylarion_path, config.project_id) default_queries = [] if args.testcases_query is None else args.testcases_query transformer = Transformer(config) suite = Exporter(transformer) # Once the suite object has been initialized, generate a test run with associated test records if not config.generate_only: if config.update_run: update_id = config.update_run log.info("Updating test run {}".format(update_id)) tr = Exporter.get_test_run(update_id) suite.update_test_run(tr) else: suite.create_test_run(config.testrun_template) log.info("TestRun information completed to Polarion") if reset_project_id: try: import shutil backup = using_pylarion_path + ".bak" shutil.move(backup, using_pylarion_path) except Exception as ex: CLIConfigurator.set_project_id(using_pylarion_path, original_project_id) if __name__ == "__main__": config_map = kickstart() Exporter.export(config_map)
def export(result=None): """ This is the method that actually does the processing of the configuration map and does what needs to be done :param result: :return: """ if result is None: result = kickstart() translate_to_cli = cli_print(result["config"]) log.info("Calling equivalent: python -m pong.exporter {}".format(translate_to_cli)) cli_cfg = result["cli_cfg"] args = cli_cfg.args config = result["config"] # Save off our original .pylarion in case the user passes in a project-id that is different # If the user selects --set-project-id, changes from -p are permanent reset_project_id = False using_pylarion_path = config.pylarion_path original_project_id = cli_cfg.original_project_id # FIXME: Turn these into functions and decorate them if args.query_testcase: tests = query_test_case(args.query_testcase) for test in tests: msg = test.work_item_id + " " + test.title log.info(msg) if args.get_default_project_id: log.info(get_default_project()) if args.set_project: reset_project_id = True CLIConfigurator.set_project_id(config.pylarion_path, config.set_project) if args.get_latest_testrun: tr = get_latest_test_run(args.get_latest_testrun) for k, v in make_iterable(tr): print "{}={}".format(k, v) if any([args.query_testcase, args.get_default_project_id, args.get_latest_testrun]): sys.exit(0) # Get the project_id. If the passed in value is different, we need to edit the .pylarion file default_project_id = cli_cfg.original_project_id if config.project_id != default_project_id: CLIConfigurator.set_project_id(using_pylarion_path, config.project_id) default_queries = [] if args.testcases_query is None else args.testcases_query transformer = Transformer(config) suite = Exporter(transformer) # Once the suite object has been initialized, generate a test run with associated test records if not config.generate_only: if config.update_run: update_id = config.update_run log.info("Updating test run {}".format(update_id)) tr = Exporter.get_test_run(update_id) suite.update_test_run(tr) else: suite.create_test_run(config.testrun_template) log.info("TestRun information completed to Polarion") if reset_project_id: try: import shutil backup = using_pylarion_path + ".bak" shutil.move(backup, using_pylarion_path) except Exception as ex: CLIConfigurator.set_project_id(using_pylarion_path, original_project_id)
key, val = kv val = val.replace("\n", "").lstrip() key1 = "--" + key.lower().replace("_", "-") if "testrun-jenkins-jobs" in key1: key1 = "--testrun-jenkinsjobs" if key1 == "--planned-in-milestone": key1 = "--testrun-plannedin" if key1 == "--testcase-prefix": if val.endswith(":"): val += " " return key1, val cmdline_args = map(composer, map(lambda l: l.split("="), lines[1:])) # cmdline_args = zip(cmd_args, map(cfgget, keys_p)) arglist = [] for opts in cmdline_args: arglist.extend(opts) arglist.extend(["--test-case-skips", "True"]) for i, arg in enumerate(arglist): if arg == "--result-path" and args.result_path is not None: arglist[i+1] = args.result_path break config_map = kickstart(args=arglist) Exporter.export(config_map)