diff options
| author | bbangert <devnull@localhost> | 2006-03-10 20:01:39 +0000 |
|---|---|---|
| committer | bbangert <devnull@localhost> | 2006-03-10 20:01:39 +0000 |
| commit | 3bbe604517bca9e27667a503a8ef3fed23265858 (patch) | |
| tree | 9e94a61d0d7b99d0d6f3e6a5e9313d353827a19d /tests/test_registry.py | |
| parent | ffd628c46c5957725696f5bd09de36876d1171e2 (diff) | |
| download | paste-3bbe604517bca9e27667a503a8ef3fed23265858.tar.gz | |
Adding registry unit tests, fixed registry to not use weakref's so any object can be proxied (including dicts)
Diffstat (limited to 'tests/test_registry.py')
| -rw-r--r-- | tests/test_registry.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_registry.py b/tests/test_registry.py new file mode 100644 index 0000000..ab89d76 --- /dev/null +++ b/tests/test_registry.py @@ -0,0 +1,40 @@ +from paste.fixture import * +from paste.registry import * + +testobj = StackedObjectProxy() + +def simpleapp(environ, start_response): + status = '200 OK' + response_headers = [('Content-type','text/plain')] + start_response(status, response_headers) + return ['Hello world!\n'] + +class RegistryUsingApp(object): + def __init__(self, var, value): + 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) + status = '200 OK' + response_headers = [('Content-type','text/plain')] + start_response(status, response_headers) + return ['Hello world!\nThe variable is %s' % str(testobj)] + +def test_simple(): + app = TestApp(simpleapp) + response = app.get('/') + assert 'Hello world' in response + +def test_solo_registry(): + obj = {'hi':'people'} + wsgiapp = RegistryUsingApp(testobj, obj) + 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 + +
\ No newline at end of file |
