diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-04-13 20:09:37 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-04-13 20:09:37 +0000 |
| commit | b6cef5185dcb4e9ff6c26c378f65590daaa8d828 (patch) | |
| tree | 44e32fcfa700ae62f7255d102d3a9071b3363b2f /repoze/bfg/tests/test_testing.py | |
| parent | 223fe5414a519183192f0a95d017e968c344729c (diff) | |
| download | pyramid-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/tests/test_testing.py')
| -rw-r--r-- | repoze/bfg/tests/test_testing.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/repoze/bfg/tests/test_testing.py b/repoze/bfg/tests/test_testing.py index 1154fc27b..bd0dba5fd 100644 --- a/repoze/bfg/tests/test_testing.py +++ b/repoze/bfg/tests/test_testing.py @@ -423,6 +423,50 @@ class TestDummyRequest(unittest.TestCase): request = self._makeOne(water = 1) self.assertEqual(request.water, 1) + def test_paramcompare(self): + request = self._makeOne(params={'foo': 'bar'}) + self.assertEqual(request.params, {'foo':'bar'}) + self.assertEqual(request.GET, {'foo':'bar'}) + +class TestFauxMultiDict(unittest.TestCase): + def _getTargetClass(self): + from repoze.bfg.testing import FauxMultiDict + return FauxMultiDict + + def _makeOne(self, dict=None): + klass = self._getTargetClass() + if dict is not None: + return klass(dict) + return klass() + + def test_getall_nodefault(self): + inst = self._makeOne() + inst['a'] = 'b' + self.assertEqual(inst.getall('a'), ['b']) + + def test_getall_withdefault(self): + inst = self._makeOne({'a':'b'}) + self.assertEqual(inst.getall('a'), ['b']) + + def test_getall_notexist(self): + inst = self._makeOne({'a':'b'}) + self.assertEqual(inst.getall('nope'), []) + + def test_repr(self): + inst = self._makeOne({'a':'b'}) + r = repr(inst) + self.assertEqual(r, "{'a': 'b'}") + + def test_eq(self): + inst = self._makeOne({'a':'b'}) + self.assertEqual(inst, {'a':'b'}) + + def test_convert_to_dict(self): + inst = self._makeOne({'a':'b'}) + d = dict(inst) + self.assertEqual(d, {'a':'b'}) + + class TestDummyTemplateRenderer(unittest.TestCase): def _getTargetClass(self, ): from repoze.bfg.testing import DummyTemplateRenderer |
