def main(): parser = OptionParser(description="Upload tests cases to TestRail. " "See settings.py for configuration.") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Enable debug output") parser.add_option("-r", "--rewrite", action="store_true", dest="rewrite", default=False, help="Rewrite all suite") parser.add_option("-u", "--update", action="store_true", dest="update", default=False, help="Update new cases to suite") (options, _) = parser.parse_args() if options.verbose: logger.setLevel(DEBUG) testrail_project = TestRailProject(url=TestRailSettings.url, user=TestRailSettings.user, password=TestRailSettings.password, project=TestRailSettings.project) testrail_milestone = testrail_project.get_milestone_by_name( name=TestRailSettings.milestone) testrail_default_test_priority = [ priority['id'] for priority in testrail_project.get_priorities() if priority['is_default'] is True ][0] tests_descriptions = get_tests_descriptions( testrail_milestone['id'], testrail_default_test_priority, testrail_project) if options.rewrite: rewrite_tests_descriptions(testrail_project=testrail_project, tests=tests_descriptions) if options.update: add_new_tests_description(testrail_project=testrail_project, tests=tests_descriptions)
def main(): parser = OptionParser( description="Upload tests cases to TestRail. " "See settings.py for configuration." ) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Enable debug output") parser.add_option("-r", "--rewrite", action="store_true", dest="rewrite", default=False, help="Rewrite all suite") parser.add_option("-u", "--update", action="store_true", dest="update", default=False, help="Update new cases to suite") (options, _) = parser.parse_args() if options.verbose: logger.setLevel(DEBUG) testrail_project = TestRailProject( url=TestRailSettings.url, user=TestRailSettings.user, password=TestRailSettings.password, project=TestRailSettings.project ) testrail_milestone = testrail_project.get_milestone_by_name( name=TestRailSettings.milestone) testrail_default_test_priority = [priority['id'] for priority in testrail_project.get_priorities() if priority['is_default'] is True][0] tests_descriptions = get_tests_descriptions(testrail_milestone['id'], testrail_default_test_priority, testrail_project) if options.rewrite: rewrite_tests_descriptions(testrail_project=testrail_project, tests=tests_descriptions) if options.update: add_new_tests_description(testrail_project=testrail_project, tests=tests_descriptions)
def main(): parser = OptionParser( description="Upload tests cases to TestRail. " "See settings.py for configuration." ) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Enable debug output") parser.add_option('-j', '--job-name', dest='job_name', default=None, help='Jenkins swarm runner job name') parser.add_option('-N', '--build-number', dest='build_number', default='latest', help='Jenkins swarm runner build number') parser.add_option('-o', '--check_one_section', action="store_true", dest='check_one_section', default=False, help='Look for existing test case only in specified ' 'section of test suite.') parser.add_option("-l", "--live", dest="live_upload", action="store_true", help="Get tests results from running swarm") (options, _) = parser.parse_args() if options.verbose: logger.setLevel(DEBUG) if options.live_upload and options.build_number == 'latest': options.build_number = 'latest_started' project = TestRailProject( url=TestRailSettings.url, user=TestRailSettings.user, password=TestRailSettings.password, project=TestRailSettings.project ) testrail_section = project.get_section_by_name( suite_id=project.get_suite_by_name(TestRailSettings.tests_suite)['id'], section_name=TestRailSettings.tests_section ) testrail_milestone = project.get_milestone_by_name( name=TestRailSettings.milestone) testrail_default_test_priority = [priority['id'] for priority in project.get_priorities() if priority['is_default'] is True][0] distros = [config['name'].split()[0].lower() for config in project.get_config_by_name( 'Operation System')['configs'] if config['name'] in TestRailSettings.operation_systems] tests_groups = get_tests_groups_from_jenkins( options.job_name, options.build_number, distros) if options.job_name else [] # If Jenkins job build is specified, but it doesn't have downstream builds # with tests groups in jobs names, then skip tests cases uploading because # ALL existing tests cases will be uploaded if options.job_name and not tests_groups: return tests_descriptions = get_tests_descriptions( milestone_id=testrail_milestone['id'], tests_include=TestRailSettings.tests_include, tests_exclude=TestRailSettings.tests_exclude, groups=tests_groups, default_test_priority=testrail_default_test_priority ) upload_tests_descriptions(testrail_project=project, section_id=testrail_section['id'], tests=tests_descriptions, check_all_sections=not options.check_one_section)
def main(): parser = OptionParser(description="Upload tests cases to TestRail. " "See settings.py for configuration.") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Enable debug output") parser.add_option('-j', '--job-name', dest='job_name', default=None, help='Jenkins swarm runner job name') parser.add_option('-N', '--build-number', dest='build_number', default='latest', help='Jenkins swarm runner build number') parser.add_option('-o', '--check_one_section', action="store_true", dest='check_one_section', default=False, help='Look for existing test case only in specified ' 'section of test suite.') parser.add_option("-l", "--live", dest="live_upload", action="store_true", help="Get tests results from running swarm") (options, _) = parser.parse_args() if options.verbose: logger.setLevel(DEBUG) if options.live_upload and options.build_number == 'latest': options.build_number = 'latest_started' project = TestRailProject(url=TestRailSettings.url, user=TestRailSettings.user, password=TestRailSettings.password, project=TestRailSettings.project) testrail_section = project.get_section_by_name( suite_id=project.get_suite_by_name(TestRailSettings.tests_suite)['id'], section_name=TestRailSettings.tests_section) testrail_milestone = project.get_milestone_by_name( name=TestRailSettings.milestone) testrail_default_test_priority = [ priority['id'] for priority in project.get_priorities() if priority['is_default'] is True ][0] distros = [ config['name'].split()[0].lower() for config in project.get_config_by_name('Operation System')['configs'] if config['name'] in TestRailSettings.operation_systems ] tests_groups = get_tests_groups_from_jenkins( options.job_name, options.build_number, distros) if options.job_name else [] # If Jenkins job build is specified, but it doesn't have downstream builds # with tests groups in jobs names, then skip tests cases uploading because # ALL existing tests cases will be uploaded if options.job_name and not tests_groups: return tests_descriptions = get_tests_descriptions( milestone_id=testrail_milestone['id'], tests_include=TestRailSettings.tests_include, tests_exclude=TestRailSettings.tests_exclude, groups=tests_groups, default_test_priority=testrail_default_test_priority) upload_tests_descriptions(testrail_project=project, section_id=testrail_section['id'], tests=tests_descriptions, check_all_sections=not options.check_one_section)