Skip to content
Myr

Type-check test_cookies.py (#677)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Florimond Manca · committed by GitHub · parent 49e4d15 · Browse files · 1 file+11 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−9 removed

  • tests:+11 added−9 removed

1 file+11 added−9 removed

modified:tests/client/test_cookies.py+11 added-9 removed
20 unmodified lines
21 return Response(200, content=body, request=request)22 elif request.url.path.startswith("/set_cookie"):23 headers = {"set-cookie": "example-name=example-value"}24 return Response(200, headers=headers, request=request)25 else:26 raise NotImplementedError # pragma: no cover272829@pytest.mark.asyncio28async def test_set_cookie():30async def test_set_cookie() -> None:31 """32 Send a request including a cookie.33 """34 url = "http://example.org/echo_cookies"
6 unmodified lines
41 assert response.json() == {"cookies": "example-name=example-value"}424344@pytest.mark.asyncio43async def test_set_cookie_with_cookiejar():45async def test_set_cookie_with_cookiejar() -> None:46 """47 Send a request including a cookie, using a `CookieJar` instance.48 """49
14 unmodified lines
64 expires=None,65 discard=True,66 comment=None,67 comment_url=None,66 rest={"HttpOnly": None},68 rest={"HttpOnly": ""},69 rfc2109=False,70 )71 cookies.set_cookie(cookie)72
4 unmodified lines
77 assert response.json() == {"cookies": "example-name=example-value"}787980@pytest.mark.asyncio79async def test_setting_client_cookies_to_cookiejar():81async def test_setting_client_cookies_to_cookiejar() -> None:82 """83 Send a request including a cookie, using a `CookieJar` instance.84 """85
14 unmodified lines
100 expires=None,101 discard=True,102 comment=None,103 comment_url=None,102 rest={"HttpOnly": None},104 rest={"HttpOnly": ""},105 rfc2109=False,106 )107 cookies.set_cookie(cookie)108109 client = Client(dispatch=MockDispatch())108 client.cookies = cookies110 client.cookies = cookies # type: ignore111 response = await client.get(url)112113 assert response.status_code == 200114 assert response.json() == {"cookies": "example-name=example-value"}115116117@pytest.mark.asyncio116async def test_set_cookie_with_cookies_model():118async def test_set_cookie_with_cookies_model() -> None:119 """120 Send a request including a cookie, using a `Cookies` instance.121 """122
8 unmodified lines
131 assert response.json() == {"cookies": "example-name=example-value"}132133134@pytest.mark.asyncio133async def test_get_cookie():135async def test_get_cookie() -> None:136 url = "http://example.org/set_cookie"137138 client = Client(dispatch=MockDispatch())139 response = await client.get(url)
3 unmodified lines
143 assert client.cookies["example-name"] == "example-value"144145146@pytest.mark.asyncio145async def test_cookie_persistence():147async def test_cookie_persistence() -> None:148 """149 Ensure that Client instances persist cookies between requests.150 """151 client = Client(dispatch=MockDispatch())
13 unmodified lines