Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
0
def format_request_cookies(fields):
    return format_cookies(cookies.group_cookies(fields))
Esempio n. 4
0
def format_request_cookies(fields):
    return format_cookies(cookies.group_cookies(fields))