summaryrefslogtreecommitdiff
path: root/repoze/bfg/testing.py
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2009-01-07 13:09:22 +0000
committerTres Seaver <tseaver@palladion.com>2009-01-07 13:09:22 +0000
commit6801b595308651a4d103b2e1c45d4f5387e151e5 (patch)
treefd59355734abbef1a63177b779b6f12a88602781 /repoze/bfg/testing.py
parent3ede8b4c71fb8ee15633819b05180624d3b28ea8 (diff)
downloadpyramid-6801b595308651a4d103b2e1c45d4f5387e151e5.tar.gz
pyramid-6801b595308651a4d103b2e1c45d4f5387e151e5.tar.bz2
pyramid-6801b595308651a4d103b2e1c45d4f5387e151e5.zip
Add a 'post' argument to the DummyRequest ctor.
Diffstat (limited to 'repoze/bfg/testing.py')
-rw-r--r--repoze/bfg/testing.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/repoze/bfg/testing.py b/repoze/bfg/testing.py
index 3480184bd..5a90033c7 100644
--- a/repoze/bfg/testing.py
+++ b/repoze/bfg/testing.py
@@ -306,17 +306,26 @@ class DummyModel:
return inst
class DummyRequest:
- """ A dummy request object (imitates a :term:`WebOb` ``Request``
- object). The named constructor arguments correspond to their
- WebOb equivalents. Extra keyword arguments are assigned as
- attributes of the request itself."""
+ """ A dummy request object (imitates a :term:`WebOb` ``Request`` object).
+
+ The ``params``, ``environ``, ``headers``, ``path``, and ``cookies``
+ arguments correspond to their WebOb equivalents.
+
+ The ``post`` argument, if passed, populates the request's
+ ``POST`` attribute, but *not* ``params``, in order to allow testing
+ that the app accepts data for a given view only from POST requests.
+ This argument also sets ``self.method`` to "POST".
+
+ Extra keyword arguments are assigned as attributes of the request
+ itself.
+ """
implements(IRequest)
method = 'GET'
application_url = 'http://example.com'
host = 'example.com:80'
content_length = 0
def __init__(self, params=None, environ=None, headers=None, path='/',
- cookies=None, **kw):
+ cookies=None, post=None, **kw):
if environ is None:
environ = {}
if params is None:
@@ -330,7 +339,11 @@ class DummyRequest:
self.params = params
self.cookies = cookies
self.GET = params
- self.POST = params
+ if post is not None:
+ self.method = 'POST'
+ self.POST = post
+ else:
+ self.POST = params
self.host_url = self.application_url
self.path_url = self.application_url
self.url = self.application_url