MCPcopy Create free account
hub / github.com/apify/crawlee-python / test_convert_dict_format

Function test_convert_dict_format

tests/unit/sessions/test_cookies.py:74–91  ·  view source on GitHub ↗

Test normalizing cookie attributes between internal and browser formats.

(session_cookies: SessionCookies)

Source from the content-addressed store, hash-verified

72
73
74def test_convert_dict_format(session_cookies: SessionCookies) -> None:
75 """Test normalizing cookie attributes between internal and browser formats."""
76 internal_format = CookieParam({'name': 'test', 'value': 'value', 'http_only': True, 'same_site': 'Lax'})
77
78 # Test internal to browser format
79 browser_format = session_cookies._to_playwright(internal_format)
80 assert 'httpOnly' in browser_format
81 assert 'sameSite' in browser_format
82 assert 'http_only' not in browser_format
83 assert 'same_site' not in browser_format
84
85 # Test browser to internal format
86 browser_format = PlaywrightCookieParam({'name': 'test', 'value': 'value', 'httpOnly': True, 'sameSite': 'Lax'})
87 internal_format = session_cookies._from_playwright(browser_format)
88 assert 'http_only' in internal_format
89 assert 'same_site' in internal_format
90 assert 'httpOnly' not in internal_format
91 assert 'sameSite' not in internal_format
92
93
94def test_get_cookies_as_browser_format(session_cookies: SessionCookies, cookie_dict: CookieParam) -> None:

Callers

nothing calls this directly

Calls 4

CookieParamClass · 0.90
_to_playwrightMethod · 0.80
_from_playwrightMethod · 0.80

Tested by

no test coverage detected