diff options
| author | ianb <devnull@localhost> | 2005-05-15 01:09:15 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-05-15 01:09:15 +0000 |
| commit | 5b78e03a2cc8ec4c68fc8de9a886255d2f3a922e (patch) | |
| tree | 24885fcb23b8a4a1de0dfd4fd6585655dfdbef98 /examples | |
| parent | 95ffc2827724c9b488b3f143afc0e39e49daaa0a (diff) | |
| download | paste-5b78e03a2cc8ec4c68fc8de9a886255d2f3a922e.tar.gz | |
Added test using fixture; fixed SQLObject configuration and loading
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/todo_wareweb/__init__.py | 1 | ||||
| -rw-r--r-- | examples/todo_wareweb/test_site.py | 42 | ||||
| -rw-r--r-- | examples/todo_wareweb/web/__init__.py | 3 |
3 files changed, 44 insertions, 2 deletions
diff --git a/examples/todo_wareweb/__init__.py b/examples/todo_wareweb/__init__.py index 0454673..3415d9d 100644 --- a/examples/todo_wareweb/__init__.py +++ b/examples/todo_wareweb/__init__.py @@ -3,3 +3,4 @@ from paste.util.thirdparty import add_package add_package('ZopePageTemplates') add_package('Component') add_package('ZPTKit') +add_package('sqlobject') diff --git a/examples/todo_wareweb/test_site.py b/examples/todo_wareweb/test_site.py new file mode 100644 index 0000000..e3be50c --- /dev/null +++ b/examples/todo_wareweb/test_site.py @@ -0,0 +1,42 @@ +import sys, os +sys.path.append(os.path.dirname(os.path.dirname(__file__))) +from paste.tests.fixture import setup_module +from todo_wareweb.db import * +import sqlobject + +def test_index(): + res = app.get('/') + res.mustcontain('List of Lists') + for lst in TodoList.select(): + res.mustcontain(lst.description) + +def test_make_list(): + res = app.post('/edit_list', + params=dict(id='new', + _action_='save', + description='New list')) + res = res.follow() + res.mustcontain('List: New list') + res.mustcontain('No items to display') + lists = list(TodoList.selectBy(description='New list')) + assert len(lists) == 1 + +def reset_state(): + sqlobject.sqlhub.processConnection = sqlobject.connectionForURI( + CONFIG['database']) + for item in TodoItem.select(): + item.destroySelf() + for lst in TodoList.select(): + lst.destroySelf() + l1 = TodoList(description='Grocery List') + TodoItem(todo_list=l1, + description='Apples') + TodoItem(todo_list=l1, + description='Comet', + done=True) + TodoItem(todo_list=l1, + description='Oranges') + l2 = TodoList(description='Bills to pay') + TodoItem(todo_list=l2, + description='Electricity') + diff --git a/examples/todo_wareweb/web/__init__.py b/examples/todo_wareweb/web/__init__.py index 0fca385..44f70ad 100644 --- a/examples/todo_wareweb/web/__init__.py +++ b/examples/todo_wareweb/web/__init__.py @@ -1,5 +1,4 @@ from paste.util import thirdparty -thirdparty.add_package('sqlobject') import sqlobject from todo_wareweb import db @@ -25,5 +24,5 @@ def urlparser_wrap(environ, start_response, app): try: return app(environ, start_response) finally: - sqlobject.sqlhub.threadConnection = None + del sqlobject.sqlhub.threadConnection |
