Skip to content

Commit

Permalink
Type-check test_cookies.py (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca authored Dec 23, 2019
1 parent 49e4d15 commit 0ee0005
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tests/client/test_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ async def send(
elif request.url.path.startswith("/set_cookie"):
headers = {"set-cookie": "example-name=example-value"}
return Response(200, headers=headers, request=request)
else:
raise NotImplementedError # pragma: no cover


@pytest.mark.asyncio
async def test_set_cookie():
async def test_set_cookie() -> None:
"""
Send a request including a cookie.
"""
Expand All @@ -40,7 +42,7 @@ async def test_set_cookie():


@pytest.mark.asyncio
async def test_set_cookie_with_cookiejar():
async def test_set_cookie_with_cookiejar() -> None:
"""
Send a request including a cookie, using a `CookieJar` instance.
"""
Expand All @@ -63,7 +65,7 @@ async def test_set_cookie_with_cookiejar():
discard=True,
comment=None,
comment_url=None,
rest={"HttpOnly": None},
rest={"HttpOnly": ""},
rfc2109=False,
)
cookies.set_cookie(cookie)
Expand All @@ -76,7 +78,7 @@ async def test_set_cookie_with_cookiejar():


@pytest.mark.asyncio
async def test_setting_client_cookies_to_cookiejar():
async def test_setting_client_cookies_to_cookiejar() -> None:
"""
Send a request including a cookie, using a `CookieJar` instance.
"""
Expand All @@ -99,21 +101,21 @@ async def test_setting_client_cookies_to_cookiejar():
discard=True,
comment=None,
comment_url=None,
rest={"HttpOnly": None},
rest={"HttpOnly": ""},
rfc2109=False,
)
cookies.set_cookie(cookie)

client = Client(dispatch=MockDispatch())
client.cookies = cookies
client.cookies = cookies # type: ignore
response = await client.get(url)

assert response.status_code == 200
assert response.json() == {"cookies": "example-name=example-value"}


@pytest.mark.asyncio
async def test_set_cookie_with_cookies_model():
async def test_set_cookie_with_cookies_model() -> None:
"""
Send a request including a cookie, using a `Cookies` instance.
"""
Expand All @@ -130,7 +132,7 @@ async def test_set_cookie_with_cookies_model():


@pytest.mark.asyncio
async def test_get_cookie():
async def test_get_cookie() -> None:
url = "http://example.org/set_cookie"

client = Client(dispatch=MockDispatch())
Expand All @@ -142,7 +144,7 @@ async def test_get_cookie():


@pytest.mark.asyncio
async def test_cookie_persistence():
async def test_cookie_persistence() -> None:
"""
Ensure that Client instances persist cookies between requests.
"""
Expand Down

0 comments on commit 0ee0005

Please sign in to comment.