blob: 414de31a0c0bd3847f2969fe3b7d700c6cfb65ff [file] [log] [blame]
Andrew M. Kuchlingcdec8c72000-08-19 15:21:12 +00001# Simple test suite for Cookie.py
2
Guido van Rossumf27cc5b2001-01-17 21:43:06 +00003from test_support import verify
Andrew M. Kuchlingcdec8c72000-08-19 15:21:12 +00004import Cookie
5
6# Currently this only tests SimpleCookie
7
8cases = [
9 ('chips=ahoy; vienna=finger', {'chips':'ahoy', 'vienna':'finger'}),
10 ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;";',
Fred Drake004d5e62000-10-23 17:22:08 +000011 {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}),
12 ]
Andrew M. Kuchlingcdec8c72000-08-19 15:21:12 +000013
14for data, dict in cases:
15 C = Cookie.SimpleCookie() ; C.load(data)
Andrew M. Kuchling103d5262000-08-24 11:56:19 +000016 print repr(C)
17 print str(C)
Andrew M. Kuchlingcdec8c72000-08-19 15:21:12 +000018 for k, v in dict.items():
19 print ' ', k, repr( C[k].value ), repr(v)
Marc-André Lemburg36619082001-01-17 19:11:13 +000020 verify(C[k].value == v)
Andrew M. Kuchling103d5262000-08-24 11:56:19 +000021 print C[k]
Andrew M. Kuchlingcdec8c72000-08-19 15:21:12 +000022
23C = Cookie.SimpleCookie()
24C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
25
Marc-André Lemburg36619082001-01-17 19:11:13 +000026verify(C['Customer'].value == 'WILE_E_COYOTE')
27verify(C['Customer']['version'] == '1')
28verify(C['Customer']['path'] == '/acme')
Moshe Zadka514a1022000-08-19 15:57:33 +000029
30print C.output(['path'])
31print C.js_output()
32print C.js_output(['path'])
33
Andrew M. Kuchling103d5262000-08-24 11:56:19 +000034# Try cookie with quoted meta-data
35C = Cookie.SimpleCookie()
36C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
Marc-André Lemburg36619082001-01-17 19:11:13 +000037verify(C['Customer'].value == 'WILE_E_COYOTE')
38verify(C['Customer']['version'] == '1')
39verify(C['Customer']['path'] == '/acme')