diff options
| author | Tres Seaver <tseaver@palladion.com> | 2009-01-07 13:09:22 +0000 |
|---|---|---|
| committer | Tres Seaver <tseaver@palladion.com> | 2009-01-07 13:09:22 +0000 |
| commit | 6801b595308651a4d103b2e1c45d4f5387e151e5 (patch) | |
| tree | fd59355734abbef1a63177b779b6f12a88602781 /repoze/bfg/tests/test_testing.py | |
| parent | 3ede8b4c71fb8ee15633819b05180624d3b28ea8 (diff) | |
| download | pyramid-6801b595308651a4d103b2e1c45d4f5387e151e5.tar.gz pyramid-6801b595308651a4d103b2e1c45d4f5387e151e5.tar.bz2 pyramid-6801b595308651a4d103b2e1c45d4f5387e151e5.zip | |
Add a 'post' argument to the DummyRequest ctor.
Diffstat (limited to 'repoze/bfg/tests/test_testing.py')
| -rw-r--r-- | repoze/bfg/tests/test_testing.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/repoze/bfg/tests/test_testing.py b/repoze/bfg/tests/test_testing.py index e0faf1855..38d41be06 100644 --- a/repoze/bfg/tests/test_testing.py +++ b/repoze/bfg/tests/test_testing.py @@ -363,6 +363,12 @@ class TestDummyRequest(unittest.TestCase): self.assertEqual(request.subpath, []) self.assertEqual(request.context, None) + def test_params_explicit(self): + request = self._makeOne(params = {'foo':'bar'}) + self.assertEqual(request.params['foo'], 'bar') + self.assertEqual(request.GET['foo'], 'bar') + self.assertEqual(request.POST['foo'], 'bar') + def test_environ_explicit(self): request = self._makeOne(environ = {'PATH_INFO':'/foo'}) self.assertEqual(request.environ['PATH_INFO'], '/foo') @@ -379,19 +385,27 @@ class TestDummyRequest(unittest.TestCase): request = self._makeOne(cookies = {'type': 'gingersnap'}) self.assertEqual(request.cookies['type'], 'gingersnap') - def test_kwargs(self): - request = self._makeOne(water = 1) - self.assertEqual(request.water, 1) - - def test_with_post(self): + def test_post_explicit(self): POST = {'foo': 'bar', 'baz': 'qux'} request = self._makeOne(post=POST) self.assertEqual(request.method, 'POST') self.assertEqual(request.POST, POST) - # Unlike a normal request, *don't* put explict POST data into params: - # doing so masks a possible XSS bug in the app. + # N.B.: Unlike a normal request, passing 'post' should *not* put + # explict POST data into params: doing so masks a possible + # XSS bug in the app. Tests for apps which don't care about + # the distinction should just use 'params'. self.assertEqual(request.params, {}) + def test_post_empty_shadows_params(self): + request = self._makeOne(params={'foo': 'bar'}, post={}) + self.assertEqual(request.method, 'POST') + self.assertEqual(request.params.get('foo'), 'bar') + self.assertEqual(request.POST.get('foo'), None) + + def test_kwargs(self): + request = self._makeOne(water = 1) + self.assertEqual(request.water, 1) + class TestDummyTemplateRenderer(unittest.TestCase): def _getTargetClass(self): from repoze.bfg.testing import DummyTemplateRenderer |
