How to use the gidgethub.sansio function in gidgethub

To help you get started, we’ve selected a few gidgethub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python / bedevere / tests / test_follow_up.py View on Github external
"action": "closed",
        "pull_request": {
            "number": 5326,
            "merged": False,
            "statuses_url": "https://api.github.com/blah/blah/git-sha",
            "title": "No issue in title",
            "issue_url": "issue URL",
            "merge_commit_sha": None,
            "comments_url": "https://api.github.com/repos/python/cpython/pulls/5326/comments",
        },
        "repository": {
            "commits_url": "https://api.github.com/repos/python/cpython/commits{/sha}"
        }
    }

    event = sansio.Event(data, event="pull_request", delivery_id="12345")
    gh = FakeGH()
    await follow_up.router.dispatch(event, gh)
    post_data = gh.post_data
    assert post_data is None
github python / miss-islington / tests / test_backport_pr.py View on Github external
async def test_labeled_on_merged_pr_no_backport_label():
    data = {
        "action": "labeled",
        "pull_request": {
            "merged": True,
            "number": 1,
            "merged_by": {"login": "Mariatta"},
            "user": {"login": "Mariatta"},
            "merge_commit_sha": "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9",
        },
        "repository": {
            "issues_url": "https://api.github.com/repos/python/cpython/issues{/number}"
        },
        "label": {"name": "CLA signed"},
    }
    event = sansio.Event(data, event="pull_request", delivery_id="1")

    gh = FakeGH()
    await backport_pr.router.dispatch(event, gh)
    assert not hasattr(gh, "post_data")
    assert not hasattr(gh, "post_url")
github python / bedevere / tests / test_close_pr.py View on Github external
"issue_url": "https://api.github.com/org/repo/issues/123",
            "url": "https://api.github.com/org/repo/pulls/123",
            "head": {
                "label": "python:3.6"
            },
            "base": {
                "label": "python:master"
            }
        },
    }
    pr_data = {
        "labels": [
            {"name": "non-trivial"},
        ]
    }
    event = sansio.Event(data, event="pull_request", delivery_id="12345")
    gh = FakeGH(getitem=pr_data)
    await close_pr.router.dispatch(event, gh)
    patch_data = gh.patch_data
    assert patch_data["state"] == "closed"

    assert len(gh.post_url) == 2
    assert gh.post_url[0] == 'https://api.github.com/org/repo/issues/123/labels'
    assert gh.post_data[0] == ['invalid']
    assert gh.post_url[1] == 'https://api.github.com/org/repo/issues/123/comments'
    assert gh.post_data[1] == {'body': close_pr.INVALID_PR_COMMENT}
github python / miss-islington / tests / test_delete_branch.py View on Github external
async def test_branch_deleted_when_pr_merged():
    data = {
        "action": "closed",
        "pull_request": {
            "number": 5722,
            "user": {"login": "miss-islington"},
            "merged": True,
            "merged_by": {"login": "miss-islington"},
            "head": {"ref": "backport-17ab8f0-3.7"},
        },
    }
    event = sansio.Event(data, event="pull_request", delivery_id="1")

    gh = FakeGH()
    await delete_branch.router.dispatch(event, gh)
    assert gh.post_data is None  # does not leave a comment
    assert (
        gh.delete_url
        == f"/repos/miss-islington/cpython/git/refs/heads/{data['pull_request']['head']['ref']}"
    )
github python / bedevere / tests / test_follow_up.py View on Github external
async def getitem(self, url, url_vars={}):
        self.getitem_url = sansio.format_url(url, url_vars)
        return self._getitem_return[self.getitem_url]
github python / miss-islington / tests / test_backport_pr.py View on Github external
async def getitem(self, url, url_vars={}):
        self.getitem_url = sansio.format_url(url, url_vars)
        return self._getitem_return[self.getitem_url]
github Mariatta / black_out / black_out / util.py View on Github external
def get_request_headers():
    username = os.environ.get("GH_USERNAME")
    gh_auth = os.environ.get("GH_AUTH")
    return sansio.create_headers(username, oauth_token=gh_auth)
github brettcannon / gidgethub / gidgethub / abc.py View on Github external
def __init__(self, requester: str, *, oauth_token: Opt[str] = None,
                 cache: Opt[CACHE_TYPE] = None) -> None:
        self.requester = requester
        self.oauth_token = oauth_token
        self._cache = cache
        self.rate_limit: Opt[sansio.RateLimit] = None