def test_cli_print(self): example = """1455653630.7-pong.logger-INFO: result_path=http://my-jenkins.comjob/jsefler-subscription-manager-rhel-6.8-x86_64-Tier3Tests/23/artifact/test-output/testng-results.xml 1455653630.7-pong.logger-INFO: query_testcase=False 1455653630.7-pong.logger-INFO: get_default_project_id=False 1455653630.7-pong.logger-INFO: pylarion_path=/home/jenkins/.pylarion 1455653630.7-pong.logger-INFO: exporter_config=/home/jenkins/exporter.yml 1455653630.7-pong.logger-INFO: update_run=False 1455653630.7-pong.logger-INFO: testrun_prefix=RHSM 1455653630.7-pong.logger-INFO: testrun_template=RHSM RHEL6-8 1455653630.7-pong.logger-INFO: get_latest_testrun=False 1455653630.7-pong.logger-INFO: set_project=False 1455653630.7-pong.logger-INFO: base_queries=['rhsm.*.tests*'] 1455653630.7-pong.logger-INFO: project_id=RHEL6 1455653630.7-pong.logger-INFO: generate_only=False 1455653630.7-pong.logger-INFO: testrun_suffix=Server x86_64 Run 1455653630.7-pong.logger-INFO: artifact_archive=test-output/testng-results.xml 1455653630.7-pong.logger-INFO: distro=Distro(major='6', arch='x86_64', variant='Server', name='Red Hat Enterprise Linux', minor='8')""" args = extractor(example) cli_args = cli_print(args) print cli_args
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)