--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dbtestcase.py Mon Jan 30 23:28:14 2012 +0100
@@ -0,0 +1,24 @@
+import unittest
+
+from iro.model import schema
+from iro.model.utils import WithSession
+
+class DBTestCase(unittest.TestCase):
+ '''a TestCase with DB connection
+ you have to set self.session manually in setUp'''
+ def __init__(self,*args,**kwargs):
+ self.engine=None
+ unittest.TestCase.__init__(self,*args,**kwargs)
+
+ def tearDown(self):
+ self.__cleanDB()
+
+ def session(self,autocommit=True):
+ '''returns a WithSession'''
+ return WithSession(self.engine,autocommit)
+
+ def __cleanDB(self):
+ '''cleaning database'''
+ with self.session() as session:
+ for table in schema.__tables__:
+ session.query(getattr(schema,table)).delete()