Skip to content

Commit

Permalink
Change: Improve GitHub async client stream tests
Browse files Browse the repository at this point in the history
The Github async client stream methods returns a async context manager.
Improve the tests in this regards and also get rid of the
`RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never
awaited` warnings.
  • Loading branch information
bjoernricks committed Oct 25, 2022
1 parent 5172e57 commit e7b6b5b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/github/api/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,14 @@ async def test_post_url(self):
content=None,
)

def test_stream(self):
self.client.stream("/foo/bar")
async def test_stream(self):
response = MagicMock()
response.__aenter__.return_value = MagicMock()
self.http_client.stream = MagicMock()
self.http_client.stream.return_value = response

async with self.client.stream("/foo/bar"):
pass

self.http_client.stream.assert_called_once_with(
"GET",
Expand All @@ -164,8 +170,14 @@ def test_stream(self):
follow_redirects=True,
)

def test_stream_url(self):
self.client.stream("https://github.com/foo/bar")
async def test_stream_url(self):
response = MagicMock()
response.__aenter__.return_value = MagicMock()
self.http_client.stream = MagicMock()
self.http_client.stream.return_value = response

async with self.client.stream("https://github.com/foo/bar"):
pass

self.http_client.stream.assert_called_once_with(
"GET",
Expand Down

0 comments on commit e7b6b5b

Please sign in to comment.