Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 2081:fb4bf55b94d7 | 2082:c091cacdc505 |
|---|---|
| 1 import os, shutil, unittest | |
| 2 | |
| 3 from db_test_base import config | |
| 4 | |
| 5 class SessionTest(unittest.TestCase): | |
| 6 def setUp(self): | |
| 7 # remove previous test, ignore errors | |
| 8 if os.path.exists(config.DATABASE): | |
| 9 shutil.rmtree(config.DATABASE) | |
| 10 os.makedirs(config.DATABASE + '/files') | |
| 11 self.db = self.module.Database(config, 'admin') | |
| 12 self.sessions = self.sessions_module.Sessions(self.db) | |
| 13 self.otks = self.sessions_module.OneTimeKeys(self.db) | |
| 14 | |
| 15 def tearDown(self): | |
| 16 del self.otks | |
| 17 del self.sessions | |
| 18 if hasattr(self, 'db'): | |
| 19 self.db.close() | |
| 20 if os.path.exists(config.DATABASE): | |
| 21 shutil.rmtree(config.DATABASE) | |
| 22 | |
| 23 def testSetSession(self): | |
| 24 self.sessions.set('random_key', text='hello, world!') | |
| 25 self.assertEqual(self.sessions.get('random_key', 'text'), | |
| 26 'hello, world!') | |
| 27 | |
| 28 def testUpdateSession(self): | |
| 29 self.sessions.set('random_key', text='hello, world!') | |
| 30 self.assertEqual(self.sessions.get('random_key', 'text'), | |
| 31 'hello, world!') | |
| 32 self.sessions.set('random_key', text='nope') | |
| 33 self.assertEqual(self.sessions.get('random_key', 'text'), 'nope') | |
| 34 | |
| 35 def testSetOTK(self): | |
| 36 assert 0, 'not implemented' | |
| 37 | |
| 38 def testExpiry(self): | |
| 39 assert 0, 'not implemented' | |
| 40 | |
| 41 class DBMTest(SessionTest): | |
| 42 import roundup.backends.sessions_dbm as sessions_module | |
| 43 | |
| 44 class RDBMSTest(SessionTest): | |
| 45 import roundup.backends.sessions_rdbms as sessions_module | |
| 46 |
