Mercurial > wikked
view tests/test_db.py @ 224:d45450a0256a
Various changes/improvements:
* Nicer init/deinit loop in Wiki class.
* Renamed `wk cache` to `wk resolve`, made resolving pages a 1st class API on
the Wiki class.
* The `wk update` command now takes a path instead of an URL.
* Re-implemented auto-updating pages when their file has changed. This added a
new `isCacheValid` function on the DB layer.
* Got rid of exceptions with some meta-properties being arrays and some not.
Now they're all arrays, but there's some helper functions to work with that.
* Remove trailing empty lines from multi-line meta-properties.
* Fixed some issues parsing multi-line meta-properties and queries.
* Fixed some issues resolving queries, especially with custom item templates.
* Better handling of page/wiki permissions.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 10 Mar 2014 16:47:21 -0700 |
parents | 2733871775cd |
children | ebb12ff21cb2 |
line wrap: on
line source
import os.path from tests import WikkedTest from mock import MockFileSystem from wikked.fs import FileSystem from wikked.db import SQLiteDatabase class DatabaseTest(WikkedTest): def tearDown(self): if hasattr(self, 'wiki') and self.wiki: self.wiki.db.close() WikkedTest.tearDown(self) def testEmpty(self): self.wiki = self._getWikiFromStructure({}) self.assertEqual([], list(self.wiki.getPageUrls())) def testOnePage(self): self.wiki = self._getWikiFromStructure({ 'foo.txt': 'A test page.' }) self.assertEqual(['foo'], list(self.wiki.getPageUrls())) page = self.wiki.getPage('foo') self.assertEqual('foo', page.url) self.assertEqual(os.path.join(self.root, 'foo.txt'), page.path) self.assertEqual('A test page.', page.raw_text) def _getWikiFromStructure(self, structure): MockFileSystem.save_structure(self.root, structure) wiki = self.getWiki( db_factory=self._dbFactory, fs_factory=self._fsFactory ) # Open the DB before we do anything so that it will be closed # only on `tearDown` (memory DBs are discarded when the # connection is closed. wiki.db.open() wiki.start() return wiki def _fsFactory(self, config): return FileSystem(self.root) def _dbFactory(self, config): return SQLiteDatabase(':memory:')