-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve transports and connection pools tests, make coverage 100%
- Loading branch information
1 parent
c0d9eeb
commit 30d8bd9
Showing
12 changed files
with
214 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
import httpx | ||
import pytest | ||
|
||
import hishel | ||
|
||
|
||
@pytest.mark.anyio | ||
async def test_client(): | ||
async with hishel.AsyncCacheClient() as client: | ||
await client.request( | ||
"GET", | ||
"https://httpbun.org/redirect/?url=https%3A//httpbun.org&status_code=301", | ||
async def test_client_301(): | ||
async with hishel.MockAsyncTransport() as transport: | ||
transport.add_responses( | ||
[httpx.Response(301, headers=[(b"Location", b"https://example.com")])] | ||
) | ||
response = await client.request( | ||
"GET", | ||
"https://httpbun.org/redirect/?url=https%3A//httpbun.org&status_code=301", | ||
) | ||
assert "network_stream" not in response.extensions # from cache | ||
async with hishel.AsyncCacheClient(transport=transport) as client: | ||
await client.request( | ||
"GET", | ||
"https://www.example.com", | ||
) | ||
response = await client.request( | ||
"GET", | ||
"https://www.example.com", | ||
) | ||
assert response.extensions["from_cache"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
import httpx | ||
import pytest | ||
|
||
import hishel | ||
|
||
|
||
|
||
def test_client(): | ||
with hishel.CacheClient() as client: | ||
client.request( | ||
"GET", | ||
"https://httpbun.org/redirect/?url=https%3A//httpbun.org&status_code=301", | ||
def test_client_301(): | ||
with hishel.MockTransport() as transport: | ||
transport.add_responses( | ||
[httpx.Response(301, headers=[(b"Location", b"https://example.com")])] | ||
) | ||
response = client.request( | ||
"GET", | ||
"https://httpbun.org/redirect/?url=https%3A//httpbun.org&status_code=301", | ||
) | ||
assert "network_stream" not in response.extensions # from cache | ||
with hishel.CacheClient(transport=transport) as client: | ||
client.request( | ||
"GET", | ||
"https://www.example.com", | ||
) | ||
response = client.request( | ||
"GET", | ||
"https://www.example.com", | ||
) | ||
assert response.extensions["from_cache"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.