Beispiel #1
0
def test_cookie_roundtrips():
    for s, expected in cookie_pairs:
        ret = cookies.parse_cookie_header(s)
        assert ret == expected

        s2 = cookies.format_cookie_header(expected)
        ret = cookies.parse_cookie_header(s2)
        assert ret == expected
Beispiel #2
0
def test_cookie_roundtrips():
    for s, expected in cookie_pairs:
        ret = cookies.parse_cookie_header(s)
        assert ret == expected

        s2 = cookies.format_cookie_header(expected)
        ret = cookies.parse_cookie_header(s2)
        assert ret == expected
Beispiel #3
0
def test_group_cookies():
    CA = cookies.CookieAttrs
    groups = [
        [
            "one=uno; foo=bar; foo=baz",
            [('one', 'uno', CA([])), ('foo', 'bar', CA([])),
             ('foo', 'baz', CA([]))]
        ],
        [
            "one=uno; Path=/; foo=bar; Max-Age=0; foo=baz; expires=24-08-1993",
            [('one', 'uno', CA([('Path', '/')])),
             ('foo', 'bar', CA([('Max-Age', '0')])),
             ('foo', 'baz', CA([('expires', '24-08-1993')]))]
        ], ["one=uno;", [('one', 'uno', CA([]))]],
        [
            "one=uno; Path=/; Max-Age=0; Expires=24-08-1993",
            [('one', 'uno',
              CA([('Path', '/'), ('Max-Age', '0'),
                  ('Expires', '24-08-1993')]))]
        ], ["path=val; Path=/", [('path', 'val', CA([('Path', '/')]))]]
    ]

    for c, expected in groups:
        observed = cookies.group_cookies(cookies.parse_cookie_header(c))
        assert observed == expected
Beispiel #4
0
def test_group_cookies():
    CA = cookies.CookieAttrs
    groups = [
        [
            "one=uno; foo=bar; foo=baz",
            [
                ('one', 'uno', CA([])),
                ('foo', 'bar', CA([])),
                ('foo', 'baz', CA([]))
            ]
        ],
        [
            "one=uno; Path=/; foo=bar; Max-Age=0; foo=baz; expires=24-08-1993",
            [
                ('one', 'uno', CA([('Path', '/')])),
                ('foo', 'bar', CA([('Max-Age', '0')])),
                ('foo', 'baz', CA([('expires', '24-08-1993')]))
            ]
        ],
        [
            "one=uno;",
            [
                ('one', 'uno', CA([]))
            ]
        ],
        [
            "one=uno; Path=/; Max-Age=0; Expires=24-08-1993",
            [
                ('one', 'uno', CA([('Path', '/'), ('Max-Age', '0'), ('Expires', '24-08-1993')]))
            ]
        ],
        [
            "path=val; Path=/",
            [
                ('path', 'val', CA([('Path', '/')]))
            ]
        ]
    ]

    for c, expected in groups:
        observed = cookies.group_cookies(cookies.parse_cookie_header(c))
        assert observed == expected