summaryrefslogtreecommitdiff
path: root/tests/test_request.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-10-10 12:00:59 -0400
committerChris McDonough <chrism@plope.com>2011-10-10 12:00:59 -0400
commit4b29bdaf6af8161320eb86ef25031afc11c4c083 (patch)
tree6aef2b2fee3496563aa793beb3271d2f481281cc /tests/test_request.py
parent7c963af17947612b3b0a67ca09bd60da12594e13 (diff)
downloadwebob-feature.cookie-bug-for-bug.tar.gz
* Mutating the ``request.cookies`` property now reflects the mutations intofeature.cookie-bug-for-bug
the ``HTTP_COOKIES`` environ header.
Diffstat (limited to 'tests/test_request.py')
-rw-r--r--tests/test_request.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/test_request.py b/tests/test_request.py
index 9120425..70956db 100644
--- a/tests/test_request.py
+++ b/tests/test_request.py
@@ -1,3 +1,4 @@
+import collections
import unittest, warnings
from webob.request import Request
from webob.request import BaseRequest
@@ -790,6 +791,16 @@ class BaseRequestTests(unittest.TestCase):
req = BaseRequest(environ)
self.assertEqual(req.cookies, {'a': 'b'})
+ def test_set_cookies(self):
+ environ = {
+ 'HTTP_COOKIE': 'a=b',
+ }
+ req = BaseRequest(environ)
+ req.cookies = {'a':'1', 'b': '2'}
+ self.assertEqual(req.cookies, {'a': '1', 'b':'2'})
+ rcookies = [x.strip() for x in environ['HTTP_COOKIE'].split(';')]
+ self.assertEqual(sorted(rcookies), ['a=1', 'b=2'])
+
def test_is_xhr_no_header(self):
req = BaseRequest({})
self.assert_(not req.is_xhr)
@@ -1531,7 +1542,7 @@ class RequestTests_functional(unittest.TestCase):
'datetime.datetime(1994, 10, 29, 19, 43, 31, tzinfo=UTC)',
"user_agent: 'Mozilla",
'is_xhr: True',
- "cookies is {",
+ "cookies is <RequestCookies",
'var1',
'value1',
'params is NestedMultiDict',
@@ -2237,7 +2248,7 @@ class RequestTests_functional(unittest.TestCase):
# Cookies
req.headers['Cookie'] = 'test=value'
- self.assert_(isinstance(req.cookies, dict))
+ self.assert_(isinstance(req.cookies, collections.MutableMapping))
self.assertEqual(list(req.cookies.items()), [('test', 'value')])
req.charset = None
self.assertEqual(req.cookies, {'test': 'value'})