diff options
| author | bbangert <devnull@localhost> | 2006-03-12 02:58:18 +0000 |
|---|---|---|
| committer | bbangert <devnull@localhost> | 2006-03-12 02:58:18 +0000 |
| commit | e1fcc940d53854a3c08e03681229265c1df56a98 (patch) | |
| tree | b8569a9e5b6b07094914b9c8333bc6b21a3d9ce1 /tests/test_registry.py | |
| parent | fffca229d33a4267b807ac2542774fc1c255db8d (diff) | |
| download | paste-e1fcc940d53854a3c08e03681229265c1df56a98.tar.gz | |
Added unit tests to ensure that TypeError is thrown if no default is provided and no object is pushed to the Proxy.
Added ability to define a default object for a StackedObjectProxy
Diffstat (limited to 'tests/test_registry.py')
| -rw-r--r-- | tests/test_registry.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/test_registry.py b/tests/test_registry.py index 8550486..f2ec717 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -1,11 +1,13 @@ # (c) 2005 Ben Bangert # This module is part of the Python Paste Project and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php +import py.test from paste.fixture import * from paste.registry import * testobj = StackedObjectProxy() +secondobj = StackedObjectProxy(default=dict(hi='people')) def simpleapp(environ, start_response): status = '200 OK' @@ -13,6 +15,19 @@ def simpleapp(environ, start_response): start_response(status, response_headers) return ['Hello world!\n'] +def simpleapp_withregistry(environ, start_response): + status = '200 OK' + response_headers = [('Content-type','text/plain')] + start_response(status, response_headers) + return ['Hello world!Value is %s\n' % testobj] + +def simpleapp_withregistry_default(environ, start_response): + status = '200 OK' + response_headers = [('Content-type','text/plain')] + start_response(status, response_headers) + return ['Hello world!Value is %s\n' % secondobj] + + class RegistryUsingApp(object): def __init__(self, var, value): self.var = var @@ -80,7 +95,18 @@ def test_solo_registry(): assert 'Hello world' in res assert 'The variable is' in res assert "{'hi': 'people'}" in res - + +def test_registry_no_object_error(): + app = TestApp(simpleapp_withregistry) + py.test.raises(TypeError, "app.get('/')") + +def test_with_default_object(): + app = TestApp(simpleapp_withregistry_default) + res = app.get('/') + print res + assert 'Hello world' in res + assert "Value is {'hi': 'people'}" in res + def test_double_registry(): obj = {'hi':'people'} secondobj = {'bye':'friends'} |
