summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/todo_wareweb/__init__.py1
-rw-r--r--examples/todo_wareweb/test_site.py42
-rw-r--r--examples/todo_wareweb/web/__init__.py3
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