view test/session_common.py @ 3826:bf2e9535da00

Journal and database testing. - Add to Import/Export test to also test that journals are correctly retrieved - Fix a bug in anydbm backend that didn't export journal 'set' actions where the previous value was None -- all other backends export them correctly so I consider this a bug of anydbm - Fix journal import/export of Date and Interval for metakit - Fix journal import of Password for metakit - Fix setting of Password oldvalue for metakit -- this would be written as the string "None" instead of the value None. Note that existing databases *will* have wrong log-entries. Since this is only for passwords -- and old passwords aren't of much importance -- I consider this fix to be enough... This fix makes the Journal import/export test run for metakit.
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Wed, 14 Mar 2007 15:23:11 +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


Roundup Issue Tracker: http://roundup-tracker.org/