summaryrefslogtreecommitdiff
path: root/repoze/bfg/testing.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-04-13 20:09:37 +0000
committerChris McDonough <chrism@agendaless.com>2009-04-13 20:09:37 +0000
commitb6cef5185dcb4e9ff6c26c378f65590daaa8d828 (patch)
tree44e32fcfa700ae62f7255d102d3a9071b3363b2f /repoze/bfg/testing.py
parent223fe5414a519183192f0a95d017e968c344729c (diff)
downloadpyramid-b6cef5185dcb4e9ff6c26c378f65590daaa8d828.tar.gz
pyramid-b6cef5185dcb4e9ff6c26c378f65590daaa8d828.tar.bz2
pyramid-b6cef5185dcb4e9ff6c26c378f65590daaa8d828.zip
- ``repoze.bfg.testing.DummyRequest`` will now contain ``params``,
``GET``, and ``POST`` attributes that are instances of the class ``FauxMultiDict``. A FauxMultiDict differs from a "plain" dictionary inasmuch as it has a ``getall`` method. ``getall`` is an interface exposed by the MultiDict implementation used by WebOb for ``params``, ``GET``, and ``POST``.
Diffstat (limited to 'repoze/bfg/testing.py')
-rw-r--r--repoze/bfg/testing.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/repoze/bfg/testing.py b/repoze/bfg/testing.py
index 1ad8ddf17..e8164bfb9 100644
--- a/repoze/bfg/testing.py
+++ b/repoze/bfg/testing.py
@@ -346,14 +346,14 @@ class DummyRequest:
cookies = {}
self.environ = environ
self.headers = headers
- self.params = params
+ self.params = FauxMultiDict(params)
self.cookies = cookies
- self.GET = params
+ self.GET = FauxMultiDict(params)
if post is not None:
self.method = 'POST'
self.POST = post
else:
- self.POST = params
+ self.POST = FauxMultiDict(params)
self.host_url = self.application_url
self.path_url = self.application_url
self.url = self.application_url
@@ -368,3 +368,17 @@ class DummyRequest:
self.marshalled = params # repoze.monty
self.__dict__.update(kw)
+class FauxMultiDict(dict):
+ """ GET, POST, and params attrs of WebOb requests are not actually
+ dictionaries; they are 'multi dicts', which means in the actual
+ implementation they can have more than one value per key. We fake
+ out a multidict here, although our implementation does not allow
+ for more than one value per key. """
+ def getall(self, key):
+ """ Return a single-valued sequence containing the value for
+ key, e.g. ['value']."""
+ val = self.get(key, _marker)
+ if val is _marker:
+ return []
+ return [val]
+