def test_storage_initializes(self): config = {'STORAGE_TYPE': 'file'} types = {'file': FakeUserStorage} factory = UserStorageFactory(storage_types=types) storage = factory.get_storage(config) self.assertTrue(isinstance(storage, FileUserStorage)) self.assertTrue(storage.initialized)
class TestUserStorageFactory(unittest.TestCase): def setUp(self): self.factory = UserStorageFactory() def test_get_storage(self): config = { 'MARKWIKI_HOME': 'nothing', 'STORAGE_TYPE': 'file' } storage = self.factory._get_storage(config) self.assertTrue(isinstance(storage, FileUserStorage)) def test_invalid_storage(self): config = {} self.assertRaises(ConfigurationError, self.factory.get_storage, config) def test_storage_initializes(self): config = {'STORAGE_TYPE': 'file'} types = {'file': FakeUserStorage} factory = UserStorageFactory(storage_types=types) storage = factory.get_storage(config) self.assertTrue(isinstance(storage, FileUserStorage)) self.assertTrue(storage.initialized)
def build_app(app_name): '''Build the application and extend it with various services.''' app = MarkWikiApp(app_name) if not app.is_bootstrapped(): print('This appears to be a new MarkWiki. Adding initial content ...') util.bootstrap(app) # Extend the app with the search engine. app.search_engine = SearchEngine(app.config['MARKWIKI_HOME']) if not app.search_engine.has_index(): app.search_engine.create_index(app.config['WIKI_PATH']) user_storage_factory = UserStorageFactory() app.user_storage = user_storage_factory.get_storage(app.config) return app
def setUp(self): self.factory = UserStorageFactory()