Mercurial > p > roundup > code
comparison test/session_common.py @ 5319:62de601bdf6f
Fix commits although a Reject exception is raised
Fix the problem that changes are committed to the database (due to
commits to otk handling) even when a Reject exception occurs. The fix
implements separate database connections for otk/session handling and
normal database operation.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Fri, 20 Apr 2018 18:46:28 +0200 |
| parents | 63c79c0992ae |
| children | d26921b851c3 |
comparison
equal
deleted
inserted
replaced
| 5318:506c7ee9a385 | 5319:62de601bdf6f |
|---|---|
| 8 # remove previous test, ignore errors | 8 # remove previous test, ignore errors |
| 9 if os.path.exists(config.DATABASE): | 9 if os.path.exists(config.DATABASE): |
| 10 shutil.rmtree(config.DATABASE) | 10 shutil.rmtree(config.DATABASE) |
| 11 os.makedirs(config.DATABASE + '/files') | 11 os.makedirs(config.DATABASE + '/files') |
| 12 self.db = self.module.Database(config, 'admin') | 12 self.db = self.module.Database(config, 'admin') |
| 13 self.sessions = self.sessions_module.Sessions(self.db) | 13 self.sessions = self.db.getSessionManager() |
| 14 self.otks = self.sessions_module.OneTimeKeys(self.db) | 14 self.otks = self.db.getOTKManager() |
| 15 | 15 |
| 16 def tearDown(self): | 16 def tearDown(self): |
| 17 del self.otks | |
| 18 del self.sessions | |
| 19 if hasattr(self, 'db'): | 17 if hasattr(self, 'db'): |
| 20 self.db.close() | 18 self.db.close() |
| 21 if os.path.exists(config.DATABASE): | 19 if os.path.exists(config.DATABASE): |
| 22 shutil.rmtree(config.DATABASE) | 20 shutil.rmtree(config.DATABASE) |
| 23 | 21 |
| 48 self.assertEqual(self.sessions.get('random_key', 'text'), | 46 self.assertEqual(self.sessions.get('random_key', 'text'), |
| 49 'hello, world!') | 47 'hello, world!') |
| 50 self.sessions.set('random_key', text='nope') | 48 self.sessions.set('random_key', text='nope') |
| 51 self.assertEqual(self.sessions.get('random_key', 'text'), 'nope') | 49 self.assertEqual(self.sessions.get('random_key', 'text'), 'nope') |
| 52 | 50 |
| 53 class DBMTest(SessionTest): | |
| 54 import roundup.backends.sessions_dbm as sessions_module | |
| 55 | |
| 56 class RDBMSTest(SessionTest): | |
| 57 import roundup.backends.sessions_rdbms as sessions_module | |
| 58 |
