diff options
| author | bbangert <devnull@localhost> | 2006-03-10 20:17:32 +0000 |
|---|---|---|
| committer | bbangert <devnull@localhost> | 2006-03-10 20:17:32 +0000 |
| commit | 7ff7a257d9eab338ec849b98f1579a4fdbf97b53 (patch) | |
| tree | 29f797e68cf73494f7a4b11fddf1c175a49a2bcc /tests/test_registry.py | |
| parent | 3bbe604517bca9e27667a503a8ef3fed23265858 (diff) | |
| download | paste-7ff7a257d9eab338ec849b98f1579a4fdbf97b53.tar.gz | |
Testing that nested registry's and using objects within nested stacks works (it does)
Diffstat (limited to 'tests/test_registry.py')
| -rw-r--r-- | tests/test_registry.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_registry.py b/tests/test_registry.py index ab89d76..87966dd 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -22,6 +22,21 @@ class RegistryUsingApp(object): start_response(status, response_headers) return ['Hello world!\nThe variable is %s' % str(testobj)] +class RegistryMiddleMan(object): + def __init__(self, app, var, value): + self.app = app + self.var = var + self.value = value + + def __call__(self, environ, start_response): + if environ.has_key('paste.registry'): + environ['paste.registry'].register(self.var, self.value) + app_response = ['Inserted by middleware!\nInsertValue is %s' % str(testobj)] + app_response.extend(self.app(environ, start_response)) + app_response.extend(['\nAppended by middleware!\nAppendValue is %s' % str(testobj)]) + return app_response + + def test_simple(): app = TestApp(simpleapp) response = app.get('/') @@ -37,4 +52,21 @@ def test_solo_registry(): assert 'The variable is' in res assert "{'hi': 'people'}" in res +def test_double_registry(): + obj = {'hi':'people'} + secondobj = {'bye':'friends'} + wsgiapp = RegistryUsingApp(testobj, obj) + wsgiapp = RegistryManager(wsgiapp) + wsgiapp = RegistryMiddleMan(wsgiapp, testobj, secondobj) + wsgiapp = RegistryManager(wsgiapp) + app = TestApp(wsgiapp) + res = app.get('/') + assert 'Hello world' in res + assert 'The variable is' in res + assert "{'hi': 'people'}" in res + assert "Inserted by middleware" in res + assert "Appended by middleware" in res + assert "InsertValue is {'bye': 'friends'}" in res + assert "AppendValue is {'bye': 'friends'}" in res +
\ No newline at end of file |
