コード例 #1
0
async def test_check_run_created_with_awaiting_merge_label_pr_is_not_merged():
    sha = "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9"
    data = {
        "action": "created",
        "check_run": {
            "head_sha": sha
        },
        "sender": {
            "login": "******"
        },
    }
    event = sansio.Event(data, event="check_run", delivery_id="1")

    gh = FakeGH()
    await check_run.router.dispatch(event, gh)
    assert not hasattr(gh, "post_data")  # does not leave a comment
    assert not hasattr(gh, "put_data")  # is not merged
コード例 #2
0
async def test_pr_not_found_for_commit():
    sha = "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9"
    data = {
        "action": "completed",
        "check_run": {
            "head_sha": sha
        },
        "sender": {
            "login": "******"
        },
    }
    event = sansio.Event(data, event="check_run", delivery_id="1")

    getitem = {
        f"/search/issues?q=type:pr+repo:python/cpython+sha:{sha}": {
            "total_count": 0,
            "items": [],
        }
    }

    gh = FakeGH(getitem=getitem)
    await check_run.router.dispatch(event, gh)
    assert not hasattr(gh, "post_data")  # does not leave a comment
    assert not hasattr(gh, "put_data")  # does not leave a comment
コード例 #3
0
async def test_ci_passed_not_automerge():
    sha = "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9"
    data = {
        "action": "completed",
        "check_run": {
            "head_sha": sha
        },
        "sender": {
            "login": "******"
        },
    }
    event = sansio.Event(data, event="check_run", delivery_id="1")

    getitem = {
        f"/repos/python/cpython/commits/{sha}/status": {
            "state":
            "success",
            "statuses": [
                {
                    "state": "success",
                    "description": "Issue report skipped",
                    "context": "bedevere/issue-number",
                },
                {
                    "state": "success",
                    "description": "The Travis CI build passed",
                    "target_url":
                    "https://travis-ci.org/python/cpython/builds/340259685?utm_source=github_status&utm_medium=notification",
                    "context": "continuous-integration/travis-ci/pr",
                },
            ],
        },
        "/repos/python/cpython/pulls/5547": {
            "user": {
                "login": "******"
            },
            "merged_by": None,
            "labels": [{
                "name": "awaiting merge"
            }, {
                "name": "CLA signed"
            }],
        },
        f"/search/issues?q=type:pr+repo:python/cpython+sha:{sha}": {
            "total_count":
            1,
            "items": [{
                "number":
                5547,
                "title":
                "bpo-32720: Fixed the replacement field grammar documentation.",
                "body":
                "\n\n`arg_name` and `element_index` are defined as `digit`+ instead of `integer`.\n(cherry picked from commit 7a561afd2c79f63a6008843b83733911d07f0119)\n\nCo-authored-by: Mariatta <*****@*****.**>",
                "labels": [{
                    "name": "awaiting merge"
                }, {
                    "name": "CLA signed"
                }],
            }],
        },
        f"/repos/python/cpython/commits/{sha}/check-runs": {
            "check_runs": [{
                "conclusion": "success",
                "name": "Travis CI - Pull Request",
                "status": "completed",
            }],
            "total_count":
            1,
        },
    }

    getiter = {
        "/repos/python/cpython/pulls/5547/commits": [{
            "sha": "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9",
            "commit": {
                "message":
                "bpo-32720: Fixed the replacement field grammar documentation."
            },
        }]
    }

    gh = FakeGH(getitem=getitem, getiter=getiter)
    await check_run.router.dispatch(event, gh)
    assert not hasattr(gh, "post_data")  # does not leave a comment
    assert not hasattr(gh, "put_data")  # does not leave a comment