summaryrefslogtreecommitdiff
path: root/tests/test_response.py
diff options
context:
space:
mode:
authorBert JW Regeer <bertjw@regeer.org>2014-11-08 21:54:36 -0700
committerBert JW Regeer <bertjw@regeer.org>2015-03-22 21:36:43 -0600
commit0c2890caa9846ad45715c7bde2fd46348b9c2ff0 (patch)
tree7ad8bcac845d0f793a55814150272eaa353c9d98 /tests/test_response.py
parentef371de5e78093efc82eb66117cbacca852c9afa (diff)
downloadwebob-0c2890caa9846ad45715c7bde2fd46348b9c2ff0.tar.gz
Documentation states expires can be timedelta
The documentation for expires incorrectly states that expires can be a timedelta, let's add a test for that.
Diffstat (limited to 'tests/test_response.py')
-rw-r--r--tests/test_response.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_response.py b/tests/test_response.py
index 9eda34d..3c5b4fd 100644
--- a/tests/test_response.py
+++ b/tests/test_response.py
@@ -683,6 +683,20 @@ def test_set_cookie_expires_is_not_None_and_max_age_is_None():
eq_(val[2], 'a=1')
assert val[3].startswith('expires')
+def test_set_cookie_expires_is_timedelta_and_max_age_is_None():
+ import datetime
+ res = Response()
+ then = datetime.timedelta(days=1)
+ res.set_cookie('a', '1', expires=then)
+ eq_(res.headerlist[-1][0], 'Set-Cookie')
+ val = [ x.strip() for x in res.headerlist[-1][1].split(';')]
+ assert len(val) == 4
+ val.sort()
+ ok_(val[0] in ('Max-Age=86399', 'Max-Age=86400'))
+ eq_(val[1], 'Path=/')
+ eq_(val[2], 'a=1')
+ assert val[3].startswith('expires')
+
def test_set_cookie_value_is_unicode():
res = Response()
val = text_(b'La Pe\xc3\xb1a', 'utf-8')