Mercurial > p > roundup > code
view test/test_memorydb.py @ 4472:34dce76bb202
Multilink fixes and optimizations:
- Optimisation: Late evaluation of Multilinks (only in rdbms backends):
previously we materialized each multilink in a Node -- this creates an
SQL query for each multilink (e.g. 'files' and 'messages' for each
line in the issue index display) -- even if the multilinks aren't
displayed. Now we compute multilinks only if they're accessed (and
keep them cached).
- Add a filter_iter similar to the existing filter call. This feature is
considered experimental. This is currently not used in the
web-interface but passes all tests for the filter call except sorting
by Multilinks (which isn't supported by SQL and isn't a sane concept
anyway). When using filter_iter instead of filter this saves a *lot*
of SQL queries: Filter returns only the IDs of Nodes in the database,
the additional content of a Node has to be fetched in a separate SQL
call. The new filter_iter also returns the IDs of Nodes (one by one,
it's an iterator) but pre-seeds the cache with the content of the
Node. The information needed for seeding the cache is retrieved in the
same SQL query as the ids.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Mon, 21 Mar 2011 20:44:39 +0000 |
| parents | f0faef4dd023 |
| children | 6e3e4f24c753 |
line wrap: on
line source
# $Id: test_memorydb.py,v 1.4 2004-11-03 01:34:21 richard Exp $ import unittest, os, shutil, time from roundup import hyperdb from db_test_base import DBTest, ROTest, SchemaTest, config, setupSchema import memorydb class memorydbOpener: module = memorydb def nuke_database(self): # really kill it self.db = None db = None def open_database(self): if self.db is None: self.db = self.module.Database(config, 'admin') return self.db def setUp(self): self.open_database() setupSchema(self.db, 1, self.module) def tearDown(self): if self.db is not None: self.db.close() # nuke and re-create db for restore def nukeAndCreate(self): self.db.close() self.nuke_database() self.db = self.module.Database(config, 'admin') setupSchema(self.db, 0, self.module) class memorydbDBTest(memorydbOpener, DBTest): pass class memorydbROTest(memorydbOpener, ROTest): def setUp(self): self.db = self.module.Database(config) setupSchema(self.db, 0, self.module) class memorydbSchemaTest(memorydbOpener, SchemaTest): pass from session_common import DBMTest class memorydbSessionTest(memorydbOpener, DBMTest): def setUp(self): self.db = self.module.Database(config, 'admin') setupSchema(self.db, 1, self.module) self.sessions = self.db.sessions def test_suite(): suite = unittest.TestSuite() print 'Including memorydb tests' suite.addTest(unittest.makeSuite(memorydbDBTest)) suite.addTest(unittest.makeSuite(memorydbROTest)) suite.addTest(unittest.makeSuite(memorydbSchemaTest)) suite.addTest(unittest.makeSuite(memorydbSessionTest)) return suite if __name__ == '__main__': runner = unittest.TextTestRunner() unittest.main(testRunner=runner) # vim: set filetype=python ts=4 sw=4 et si
