Exemplo n.º 1
0
def test_pr_checker_verify_pr_no_critical_file_changes_no_changes_requested():
    # Arrange
    args = _get_args(file_globs=[DEFAULT_GLOB], valid_labels=['label1'])
    pr = MagicMock()
    pr.get_files.return_value = [*_get_files()]
    _setup_labels(pr)
    _setup_pr_reviews(pr, with_comment_body=args.changes_reverted_message)

    pr_checker = PrChecker(args, pr)

    # Act
    pr_checker.verify_pr()

    # Asset
    pr.create_review.assert_not_called()
Exemplo n.º 2
0
def test_pr_checker_verify_pr_critical_file_changes_with_label_no_changes_requested():
    # Arrange
    args = _get_args(file_globs=[DEFAULT_GLOB], valid_labels=['label1'])
    pr = MagicMock()
    pr.get_files.return_value = [
        *_get_files(),
        MagicMock(filename=CRITICAL_FILE_CHANGE)
    ]
    _setup_labels(pr)
    _setup_pr_reviews(pr)

    pr_checker = PrChecker(args, pr)

    # Act
    pr_checker.verify_pr()

    # Asset
    pr.create_review.assert_not_called()
Exemplo n.º 3
0
def test_pr_checker_verify_pr_critical_file_changes_no_label():
    # Arrange
    args = _get_args(file_globs=[DEFAULT_GLOB], valid_labels=['not_present'])
    pr = MagicMock()
    pr.get_files.return_value = [
        *_get_files(),
        MagicMock(filename=CRITICAL_FILE_CHANGE)
    ]
    _setup_labels(pr)
    _setup_pr_reviews(pr)

    pr_checker = PrChecker(args, pr)

    # Act
    pr_checker.verify_pr()

    # Asset
    pr.create_review.assert_called_once_with(body=f'{args.required_label_message} '
                                             f'Please add one of the following '
                                             f'labels: `{args.valid_labels}` '
                                             'to confirm these changes.',
                                             event='REQUEST_CHANGES')