11 from iro.model.utils import WithSession |
11 from iro.model.utils import WithSession |
12 from iro.model.schema import Base |
12 from iro.model.schema import Base |
13 |
13 |
14 from iro.controller.pool import dbPool |
14 from iro.controller.pool import dbPool |
15 |
15 |
|
16 from .utils import DummyObserver |
|
17 |
16 class DBTestCase(unittest.TestCase): |
18 class DBTestCase(unittest.TestCase): |
17 '''a TestCase with DB connection |
19 '''a TestCase with DB connection |
18 you have to set self.session manually in setUp''' |
20 you have to set self.session manually in setUp''' |
19 def __init__(self,*args,**kwargs): |
21 def __init__(self,*args,**kwargs): |
20 unittest.TestCase.__init__(self,*args,**kwargs) |
22 unittest.TestCase.__init__(self,*args,**kwargs) |
21 self.engine = md.engine |
23 self.engine = md.engine |
22 |
24 |
23 def setUp(self): |
25 def setUp(self): |
24 md.setUp() |
26 md.setUp() |
|
27 self.log = DummyObserver() |
|
28 self.log.start() |
25 |
29 |
26 def tearDown(self): |
30 def tearDown(self): |
|
31 self.log.stop() |
27 self.__cleanDB() |
32 self.__cleanDB() |
28 |
33 |
29 def session(self,autocommit=True): |
34 def session(self,autocommit=True): |
30 '''returns a WithSession''' |
35 '''returns a WithSession''' |
31 return WithSession(self.engine,autocommit) |
36 return WithSession(self.engine,autocommit) |