Mercurial > p > roundup > code
view test/session_common.py @ 3681:b9301ae1c34d
Added a test case for string comparison:
- For now allow both with and without case-sensitive comparison. In my
test Anydbm, Metakit and MySQL compare without case while Postgres
and SQLite compare with case.
Maybe the collation sequence should be defined by a backend language
option in the configuration?
Note that this *will* be a problem when Multilink-Sorting is
implemented in a generic module: In that case the string comparison
will differ when Multilinks are used in a query :-(
- When reviewing the source code for sorting in the various backends I
discovered an obscure piece of code in back_anydb::
if isinstance(propclass, hyperdb.String):
# it might be a string that's really an integer
try: tv = int(v)
except: v = v.lower()
else: v = tv
This tries to convert strings to integers. Bad. Maybe a misguided
attempt at fixing the sorting by id to be numeric (no this won't do
it) I've added a test that only anydbm fails.
I will remove that bug in the upcoming transitive sorting.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Sun, 20 Aug 2006 10:16:03 +0000 |
| parents | 93f03c6714d8 |
| children | cc33dc9aa3f2 |
line wrap: on
line source
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') class DBMTest(SessionTest): import roundup.backends.sessions_dbm as sessions_module class RDBMSTest(SessionTest): import roundup.backends.sessions_rdbms as sessions_module
