Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
aad78f22
Commit
aad78f22
authored
Apr 27, 2009
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for special attributes passed to 'setCookie'.
parent
7669068c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
2 deletions
+80
-2
src/ZPublisher/tests/testHTTPResponse.py
src/ZPublisher/tests/testHTTPResponse.py
+80
-2
No files found.
src/ZPublisher/tests/testHTTPResponse.py
View file @
aad78f22
...
@@ -30,14 +30,92 @@ class HTTPResponseTests(unittest.TestCase):
...
@@ -30,14 +30,92 @@ class HTTPResponseTests(unittest.TestCase):
response
.
setStatus
(
exc_type
)
response
.
setStatus
(
exc_type
)
self
.
assertEqual
(
response
.
status
,
code
)
self
.
assertEqual
(
response
.
status
,
code
)
def
test_setCookie
(
self
):
def
test_setCookie
_no_attrs
(
self
):
response
=
self
.
_makeOne
()
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
path
=
'/'
)
response
.
setCookie
(
'foo'
,
'bar'
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
assertEqual
(
len
(
cookie
),
1
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
cookies
=
response
.
_cookie_list
()
self
.
assertEqual
(
len
(
cookies
),
1
)
self
.
assertEqual
(
cookies
[
0
],
'Set-Cookie: foo="bar"'
)
def
test_setCookie_w_expires
(
self
):
EXPIRES
=
'Wed, 31-Dec-97 23:59:59 GMT'
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
expires
=
EXPIRES
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
failUnless
(
cookie
)
self
.
failUnless
(
cookie
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
self
.
assertEqual
(
cookie
.
get
(
'expires'
),
EXPIRES
)
cookies
=
response
.
_cookie_list
()
self
.
assertEqual
(
len
(
cookies
),
1
)
self
.
assertEqual
(
cookies
[
0
],
'Set-Cookie: foo="bar"; Expires=%s'
%
EXPIRES
)
def
test_setCookie_w_domain
(
self
):
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
domain
=
'example.com'
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
assertEqual
(
len
(
cookie
),
2
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
self
.
assertEqual
(
cookie
.
get
(
'domain'
),
'example.com'
)
cookies
=
response
.
_cookie_list
()
self
.
assertEqual
(
len
(
cookies
),
1
)
self
.
assertEqual
(
cookies
[
0
],
'Set-Cookie: foo="bar"; Domain=example.com'
)
def
test_setCookie_w_path
(
self
):
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
path
=
'/'
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
assertEqual
(
len
(
cookie
),
2
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
self
.
assertEqual
(
cookie
.
get
(
'path'
),
'/'
)
self
.
assertEqual
(
cookie
.
get
(
'path'
),
'/'
)
cookies
=
response
.
_cookie_list
()
self
.
assertEqual
(
len
(
cookies
),
1
)
self
.
assertEqual
(
cookies
[
0
],
'Set-Cookie: foo="bar"; Path=/'
)
def
test_setCookie_w_comment
(
self
):
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
comment
=
'COMMENT'
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
assertEqual
(
len
(
cookie
),
2
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
self
.
assertEqual
(
cookie
.
get
(
'comment'
),
'COMMENT'
)
cookies
=
response
.
_cookie_list
()
self
.
assertEqual
(
len
(
cookies
),
1
)
self
.
assertEqual
(
cookies
[
0
],
'Set-Cookie: foo="bar"; Comment=COMMENT'
)
def
test_setCookie_w_secure_true_value
(
self
):
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
secure
=
'SECURE'
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
assertEqual
(
len
(
cookie
),
2
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
self
.
assertEqual
(
cookie
.
get
(
'secure'
),
'SECURE'
)
cookies
=
response
.
_cookie_list
()
self
.
assertEqual
(
len
(
cookies
),
1
)
self
.
assertEqual
(
cookies
[
0
],
'Set-Cookie: foo="bar"; Secure'
)
def
test_setCookie_w_secure_false_value
(
self
):
response
=
self
.
_makeOne
()
response
.
setCookie
(
'foo'
,
'bar'
,
secure
=
''
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
assertEqual
(
len
(
cookie
),
2
)
self
.
assertEqual
(
cookie
.
get
(
'value'
),
'bar'
)
self
.
assertEqual
(
cookie
.
get
(
'secure'
),
''
)
cookies
=
response
.
_cookie_list
()
self
.
assertEqual
(
len
(
cookies
),
1
)
self
.
assertEqual
(
cookies
[
0
],
'Set-Cookie: foo="bar"'
)
def
test_expireCookie
(
self
):
def
test_expireCookie
(
self
):
response
=
self
.
_makeOne
()
response
=
self
.
_makeOne
()
response
.
expireCookie
(
'foo'
,
path
=
'/'
)
response
.
expireCookie
(
'foo'
,
path
=
'/'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment