def new_notebook(fakedir=None): '''Returns a new Notebook object with all data in memory Uses data from L{WikiTestData} @param fakedir: optional parameter to set the 'dir' attribute for the notebook and the main store which allows you to resolve file paths etc. It will not automatically touch the dir (hence it being 'fake'). ''' from zim.fs import Dir from zim.notebook import Notebook, Path from zim.index import Index notebook = Notebook(index=Index(dbfile=':memory:')) store = notebook.add_store(Path(':'), 'memory') manifest = [] for name, text in WikiTestData: manifest.append(name) store.set_node(Path(name), text) notebook.testdata_manifest = _expand_manifest(manifest) notebook.index.update() if fakedir: dir = Dir(fakedir) notebook.dir = dir store.dir = dir return notebook
def get_test_notebook(format='wiki'): '''Returns a notebook with a memory store and some test data''' from zim.notebook import Notebook, Path from zim.index import Index notebook = Notebook(index=Index(dbfile=':memory:')) store = notebook.add_store(Path(':'), 'memory') manifest = [] for name, text in get_test_data(format): manifest.append(name) store.set_node(Path(name), text) notebook.testdata_manifest = expand_manifest(manifest) return notebook
def get_test_page(name='Foo'): '''FIXME''' from zim.notebook import Notebook, Path notebook = Notebook() notebook.add_store(Path(':'), 'memory') return notebook, notebook.get_page(Path(name))