MCPcopy Create free account
hub / github.com/apify/impit / test_cookie_jar_works

Method test_cookie_jar_works

impit-python/test/async_client_test.py:196–231  ·  view source on GitHub ↗
(self, browser: Browser)

Source from the content-addressed store, hash-verified

194
195 @pytest.mark.asyncio
196 async def test_cookie_jar_works(self, browser: Browser) -> None:
197 cookies = Cookies({'preset-cookie': '123'})
198
199 impit = AsyncClient(
200 browser=browser,
201 cookie_jar=cookies.jar,
202 )
203
204 response = json.loads(
205 (
206 await impit.get(
207 get_httpbin_url('/cookies'),
208 )
209 ).text
210 )
211
212 assert response['cookies'] == {'preset-cookie': '123'}
213
214 await impit.get(
215 get_httpbin_url('/cookies/set', query={'set-by-server': '321'}),
216 )
217
218 response = json.loads(
219 (
220 await impit.get(
221 get_httpbin_url('/cookies'),
222 )
223 ).text
224 )
225
226 assert response['cookies'] == {
227 'preset-cookie': '123',
228 'set-by-server': '321',
229 }
230
231 assert len(cookies.jar) == 2
232
233 @pytest.mark.asyncio
234 async def test_cookies_param_works(self, browser: Browser) -> None:

Callers

nothing calls this directly

Calls 4

getMethod · 0.95
CookiesClass · 0.90
AsyncClientClass · 0.90
get_httpbin_urlFunction · 0.85

Tested by

no test coverage detected