Skip to content

Commit

Permalink
Change: Allow to pass a full url to async github client stream method
Browse files Browse the repository at this point in the history
Some GitHub download URLs are not API urls. Therefore allow to pass full
URLs to the stream client method.
  • Loading branch information
bjoernricks committed Oct 25, 2022
1 parent 9ffe500 commit 11d7c13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pontos/github/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def stream(self, api: str) -> AsyncContextManager[httpx.Response]:
api: API path to use for the post request
"""
headers = self._request_headers()
url = self._request_api_url(api)
url = api if api.startswith("https") else self._request_api_url(api)
return self._client.stream(
"GET", url, headers=headers, follow_redirects=True
)
Expand Down
13 changes: 13 additions & 0 deletions tests/github/api/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ def test_stream(self):
follow_redirects=True,
)

def test_stream_url(self):
self.client.stream("https://github.com/foo/bar")

self.http_client.stream.assert_called_once_with(
"GET",
"https://github.com/foo/bar",
headers={
"Accept": "application/vnd.github.v3+json",
"Authorization": "token token",
},
follow_redirects=True,
)

async def test_context_manager(self):
async with self.client:
pass
Expand Down

0 comments on commit 11d7c13

Please sign in to comment.