Mercurial > p > roundup > code
diff test/session_common.py @ 2082:c091cacdc505
Finished implementation of session and one-time-key stores for RDBMS backends.
Refactored the API of sessions and their interaction with the
backend database a fair bit too.
Added some session tests. Nothing testing ageing yet, 'cos that's a pain
inna ass to test :)
Note: metakit backend still uses the *dbm implementation. It might
want to implement its own session store some day, as it'll be faster than
the *dbm one.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 18 Mar 2004 01:58:46 +0000 |
| parents | |
| children | 93f03c6714d8 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/session_common.py Thu Mar 18 01:58:46 2004 +0000 @@ -0,0 +1,46 @@ +import os, shutil, unittest + +from db_test_base import config + +class SessionTest(unittest.TestCase): + def setUp(self): + # remove previous test, ignore errors + if os.path.exists(config.DATABASE): + shutil.rmtree(config.DATABASE) + os.makedirs(config.DATABASE + '/files') + self.db = self.module.Database(config, 'admin') + self.sessions = self.sessions_module.Sessions(self.db) + self.otks = self.sessions_module.OneTimeKeys(self.db) + + def tearDown(self): + del self.otks + del self.sessions + if hasattr(self, 'db'): + self.db.close() + if os.path.exists(config.DATABASE): + shutil.rmtree(config.DATABASE) + + def testSetSession(self): + self.sessions.set('random_key', text='hello, world!') + self.assertEqual(self.sessions.get('random_key', 'text'), + 'hello, world!') + + def testUpdateSession(self): + self.sessions.set('random_key', text='hello, world!') + self.assertEqual(self.sessions.get('random_key', 'text'), + 'hello, world!') + self.sessions.set('random_key', text='nope') + self.assertEqual(self.sessions.get('random_key', 'text'), 'nope') + + def testSetOTK(self): + assert 0, 'not implemented' + + def testExpiry(self): + assert 0, 'not implemented' + +class DBMTest(SessionTest): + import roundup.backends.sessions_dbm as sessions_module + +class RDBMSTest(SessionTest): + import roundup.backends.sessions_rdbms as sessions_module +
