Esempio n. 1
0
def test_reminder_comments_on_referenced_bugs_are_posted():
    args = bugrefs_test_args_factory()
    args.verbose_test = 1
    args.query_issue_status = True
    args.dry_run = True
    report = openqa_review.generate_report(args)

    # test double comment prevention code
    p, pr = list(iteritems(report.report))[0]
    report.report[p + 237] = pr

    openqa_review.reminder_comment_on_issues(report)
    args.dry_run = False
def test_bugrefs_are_used_for_triaging():
    # python openqa_review/openqa_review.py --load-dir tests/tags_labels --host https://openqa.opensuse.org -J https://openqa.opensuse.org/group_overview/25 -b
    # 1507,1500 --load -n > tests/tags_labels/report25_bugrefs.md
    args = cache_test_args_factory()
    args.job_groups = None
    args.bugrefs = True
    args.builds = '1507,1500'
    args.arch = 'i586'
    args.load_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                 'tags_labels')
    args.show_empty = False
    args.include_softfails = False
    args.verbose_test = 1
    openqa_review.config = ConfigParser()
    openqa_review.config.add_section('product_issues')
    openqa_review.config.set('product_issues', 'base_url',
                             'https://apibugzilla.suse.com')
    openqa_review.config.set('product_issues', 'username', 'user')
    openqa_review.config.set('product_issues', 'password', 'pass')
    openqa_review.config.set('product_issues', 'report_url',
                             'https://bugzilla.opensuse.org')
    openqa_review.config.add_section(
        'product_issues:https://openqa.opensuse.org:product_mapping')
    openqa_review.config.set(
        'product_issues:https://openqa.opensuse.org:product_mapping', '25',
        'openSUSE Tumbleweed')
    openqa_review.config.add_section(
        'product_issues:https://openqa.opensuse.org:component_mapping')
    openqa_review.config.set(
        'product_issues:https://openqa.opensuse.org:component_mapping',
        'installation-bootloader', 'Bootloader')
    openqa_review.config.add_section('test_issues')
    openqa_review.config.set('test_issues', 'api_key', '0123456789ABCDEF')
    openqa_review.config.set(
        'test_issues', 'report_url',
        'https://progress.opensuse.org/projects/openqatests/issues/new')
    report = str(openqa_review.generate_report(args))
    # report should feature bug references
    assert 'bsc#' in report
    # and references to 'test issues'
    assert 'poo#' in report
    ref_report = open(os.path.join(args.load_dir,
                                   'report25_bugrefs.md')).read()
    compare_report(report, ref_report)

    args.verbose_test = 2
    args.report_links = True
    report = str(openqa_review.generate_report(args))
    ref_report = open(os.path.join(args.load_dir,
                                   'report25_T_bugrefs.md')).read()
    compare_report(report, ref_report)

    # report bug link(s) with 'new issue'
    args.load_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                 'tags_labels/report_link_new_issue')
    args.arch = 'arm'
    report = str(openqa_review.generate_report(args))
    ref_report = open(
        os.path.join(args.load_dir,
                     'report25_bugrefs_bug_link_new_issue.md')).read()
    compare_report(report, ref_report)

    # now, with query issues
    args.verbose_test = 1
    args.report_links = False
    args.query_issue_status = True
    args.load_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                 'tags_labels')
    args.arch = 'i586'
    report = openqa_review.generate_report(args)
    ref_report = open(
        os.path.join(args.load_dir,
                     'report25_bugrefs_query_issues.md')).read()
    compare_report(report, ref_report)

    # reminder comments
    args.dry_run = True
    report = openqa_review.generate_report(args)

    # test double comment prevention code
    p, pr = list(iteritems(report.report))[0]
    report.report[p + 237] = pr

    openqa_review.reminder_comment_on_issues(report)
    args.dry_run = False

    # now, try filtering: unassigned
    report = openqa_review.generate_report(args)
    openqa_review.filter_report(report, openqa_review.ie_filters["unassigned"])
    ref_report = open(
        os.path.join(
            args.load_dir,
            'report25_bugrefs_query_issues_filter_unassigned.md')).read()
    compare_report(report, ref_report)

    # 2nd filter: closed
    report = openqa_review.generate_report(args)
    openqa_review.filter_report(report, openqa_review.ie_filters["closed"])
    ref_report = open(
        os.path.join(args.load_dir,
                     'report25_bugrefs_query_issues_filter_closed.md')).read()
    compare_report(report, ref_report)

    # report generated when no todo items are left and some bugref is not accessible
    args.builds = '1508,1500'
    args.query_issue_status = True
    report = openqa_review.generate_report(args)
    ref_report = open(
        os.path.join(args.load_dir, 'report25_bugrefs_build1508.md')).read()
    compare_report(report, ref_report)