def test_has_internal_pr_cover_letter(reqctx, requests_mocker):
    pr = make_pull_request(
        user="******",
        body="omg this code is teh awesomezors",
        head_ref="patch-1",
    )
    requests_mocker.get(
        "https://api.github.com/user",
        json={"login": "******"},
        headers={"Content-Type": "application/json"},
    )
    requests_mocker.get(
        "https://raw.githubusercontent.com/different_user/edx-platform/patch-1/.pr_cover_letter.md.j2",
        text="Fancy cover letter!",
    )

    with reqctx:
        comment_body = github_internal_cover_letter(pr)
    comments_json = [
        {
            "user": {
                "login": "******",
            },
            "body": comment_body,
        },
    ]
    requests_mocker.get(
        "https://api.github.com/repos/edx/edx-platform/issues/1/comments",
        json=comments_json,
        headers={"Content-Type": "application/json"},
    )

    with reqctx:
        result = has_internal_cover_letter(pr)
    assert result is True
def test_has_internal_pr_cover_letter(reqctx, requests_mocker):
    pr = make_pull_request(
        user="******", body="omg this code is teh awesomezors",
        head_ref="patch-1",
    )
    requests_mocker.get(
        "https://api.github.com/user",
        json={"login": "******"},
        headers={"Content-Type": "application/json"},
    )
    requests_mocker.get(
        "https://raw.githubusercontent.com/different_user/edx-platform/patch-1/.coverletter.md.j2",
        status_code=404,
    )

    with reqctx:
        comment_body = github_internal_cover_letter(pr)
    comments_json = [
        {
            "user": {
                "login": "******",
            },
            "body": comment_body,
        },
    ]
    requests_mocker.get(
        "https://api.github.com/repos/edx/edx-platform/issues/1/comments",
        json=comments_json,
        headers={"Content-Type": "application/json"},
    )

    with reqctx:
        result = has_internal_cover_letter(pr)
    assert result is True
示例#3
0
def test_internal_pr_cover_letter(reqctx):
    pr = make_pull_request(
        user="******", body="this is my first pull request",
        head_repo_name="testuser/edx-platform",
    )
    with reqctx:
        comment = github_internal_cover_letter(pr)
    assert comment is None
def test_internal_pr_cover_letter(reqctx):
    pr = make_pull_request(
        user="******",
        body="this is my first pull request",
        head_repo_name="testuser/edx-platform",
    )
    with reqctx:
        comment = github_internal_cover_letter(pr)
    assert comment is None
def test_internal_pr_cover_letter(reqctx):
    pr = make_pull_request(
        user="******", body="this is my first pull request",
        head_repo_name="testuser/edx-platform",
    )
    with reqctx:
        comment = github_internal_cover_letter(pr)
    assert "this is my first pull request" not in comment
    assert "# Sandbox" in comment
    assert "# Testing" in comment
    assert "# Reviewers" in comment
    assert "# DevOps assistance" in comment
def test_internal_pr_cover_letter(reqctx):
    pr = make_pull_request(
        user="******",
        body="this is my first pull request",
        head_repo_name="testuser/edx-platform",
    )
    with reqctx:
        comment = github_internal_cover_letter(pr)
    assert "this is my first pull request" not in comment
    assert "# Sandbox" in comment
    assert "# Testing" in comment
    assert "# Reviewers" in comment
    assert "# DevOps assistance" in comment
def test_custom_internal_pr_cover(reqctx, requests_mocker):
    pr = make_pull_request(
        user="******", body="omg this code is teh awesomezors",
        head_ref="patch-1",
    )
    requests_mocker.get(
        "https://api.github.com/user",
        json={"login": "******"},
        headers={"Content-Type": "application/json"},
    )
    requests_mocker.get(
        "https://raw.githubusercontent.com/different_user/edx-platform/patch-1/.coverletter.md.j2",
        text='custom cover letter for PR from @{{ user }}',
    )

    with reqctx:
        comment_body = github_internal_cover_letter(pr)
    assert comment_body == 'custom cover letter for PR from @different_user'
def test_custom_internal_pr_cover(reqctx, requests_mocker):
    pr = make_pull_request(
        user="******",
        body="omg this code is teh awesomezors",
        head_ref="patch-1",
    )
    requests_mocker.get(
        "https://api.github.com/user",
        json={"login": "******"},
        headers={"Content-Type": "application/json"},
    )
    requests_mocker.get(
        "https://raw.githubusercontent.com/different_user/edx-platform/patch-1/.coverletter.md.j2",
        text='custom cover letter for PR from @{{ user }}',
    )

    with reqctx:
        comment_body = github_internal_cover_letter(pr)
    assert comment_body == 'custom cover letter for PR from @different_user'