def test_parse_set_cookie_pairs(): pairs = [ ["one=uno", [[["one", "uno"]]]], ["one=un\x20", [[["one", "un\x20"]]]], ["one=uno; foo", [[["one", "uno"], ["foo", None]]]], [ "mun=1.390.f60; " "expires=sun, 11-oct-2015 12:38:31 gmt; path=/; " "domain=b.aol.com", [[["mun", "1.390.f60"], ["expires", "sun, 11-oct-2015 12:38:31 gmt"], ["path", "/"], ["domain", "b.aol.com"]]] ], [ r'rpb=190%3d1%2616726%3d1%2634832%3d1%2634874%3d1; ' 'domain=.rubiconproject.com; ' 'expires=mon, 11-may-2015 21:54:57 gmt; ' 'path=/', [[['rpb', r'190%3d1%2616726%3d1%2634832%3d1%2634874%3d1'], ['domain', '.rubiconproject.com'], ['expires', 'mon, 11-may-2015 21:54:57 gmt'], ['path', '/']]] ], ] for s, expected in pairs: ret, off = cookies._read_set_cookie_pairs(s) assert ret == expected s2 = cookies._format_set_cookie_pairs(expected[0]) ret2, off = cookies._read_set_cookie_pairs(s2) assert ret2 == expected
def test_parse_set_cookie_pairs(): pairs = [ [ "one=uno", [[ ["one", "uno"] ]] ], [ "one=un\x20", [[ ["one", "un\x20"] ]] ], [ "one=uno; foo", [[ ["one", "uno"], ["foo", None] ]] ], [ "mun=1.390.f60; " "expires=sun, 11-oct-2015 12:38:31 gmt; path=/; " "domain=b.aol.com", [[ ["mun", "1.390.f60"], ["expires", "sun, 11-oct-2015 12:38:31 gmt"], ["path", "/"], ["domain", "b.aol.com"] ]] ], [ r'rpb=190%3d1%2616726%3d1%2634832%3d1%2634874%3d1; ' 'domain=.rubiconproject.com; ' 'expires=mon, 11-may-2015 21:54:57 gmt; ' 'path=/', [[ ['rpb', r'190%3d1%2616726%3d1%2634832%3d1%2634874%3d1'], ['domain', '.rubiconproject.com'], ['expires', 'mon, 11-may-2015 21:54:57 gmt'], ['path', '/'] ]] ], ] for s, expected in pairs: ret, off = cookies._read_set_cookie_pairs(s) assert ret == expected s2 = cookies._format_set_cookie_pairs(expected[0]) ret2, off = cookies._read_set_cookie_pairs(s2) assert ret2 == expected