def test_one_cookie_as_string(cookie: Cookie): as_string = cookie._format_cookies_as_string([{ "name": "tidii", "value": 1111, "expires": -1 }]) assert as_string == "tidii=1111"
def test_cookie_as_dot_dict_negative_expiry(cookie: Cookie): epoch = -1 data = cookie._cookie_as_dot_dict({"expires": epoch}) if sys.platform == "win32": assert data.expires is None else: assert data.expires == datetime.fromtimestamp(epoch)
def test_as_dot_dict(cookie: Cookie): dot_dict = cookie._format_cookies_as_dot_dict([{ "name": "tidii", "value": 1111, "expires": -1 }]) assert dot_dict[0].name == "tidii" assert dot_dict[0].value == 1111 assert dot_dict[0].expires == datetime.fromtimestamp(-1)
def test_as_dot_dict(cookie: Cookie): dot_dict = cookie._format_cookies_as_dot_dict([{ "name": "tidii", "value": 1111, "expires": -1 }]) assert dot_dict[0].name == "tidii" assert dot_dict[0].value == 1111 if sys.platform == "win32": assert dot_dict[0].expires is None else: assert dot_dict[0].expires == datetime.fromtimestamp(-1)
def test_many_cookies_as_string(cookie: Cookie): cookies = [ { "name": "tidii", "value": 1111, "httpOnly": False }, { "name": "foo", "value": "bar", "httpOnly": True }, ] as_string = cookie._format_cookies_as_string(cookies) assert as_string == "tidii=1111; foo=bar"
def cookie(): return Cookie(None)
def test_cookie_as_dot_dict_expiry(cookie: Cookie): epoch = 1604698517 data = cookie._cookie_as_dot_dict({"expires": epoch}) assert data.expires == datetime.fromtimestamp(epoch)