def setUp(self): store = zim.stores.get_store('memory') self.store = store.Store(path=Path(':'), notebook=Notebook()) self.index = set() for name, text in tests.get_test_data('wiki'): self.store.set_node(Path(name), text) self.index.add(name) self.normalize_index()
def export(self): dir = Dir(create_tmp_dir('export_SourceFiles')) notebook = Notebook(dir=dir) for name, text in get_test_data('wiki'): page = notebook.get_page(Path(name)) page.parse('wiki', text) notebook.store_page(page) file = dir.file('Test/foo.txt') self.assertTrue(file.exists()) check_call(['python', './zim.py', '--export', '--template=Default', dir.path, '--output', self.dir.path])
def get_files_notebook(key): # We fill the notebook using the store interface, as this test comes before # the notebook test, but after the store test. dir = Dir(tests.create_tmp_dir('index_'+key)) notebook = Notebook(dir=dir) store = notebook.get_store(':') manifest = [] for name, text in tests.get_test_data('wiki'): manifest.append(name) page = store.get_page(Path(name)) page.parse('wiki', text) store.store_page(page) notebook.testdata_manifest = tests.expand_manifest(manifest) return notebook
def pytest_generate_tests(metafunc): """This method links testcase in folder tests to the test data in folder resources and creates data fixture""" def parametrize(test_data): for key, value in test_data.items(): param_keys = [k.strip() for k in key.split(',')] diff = set(param_keys) - set(metafunc.fixturenames) if diff: raise AssertionError(f'{diff} fixtures were set in JSON data, ' 'but not found in test') parameters = value if isinstance(value, list) else [value] metafunc.parametrize(key, parameters) data = get_test_data(metafunc.definition) if data: parametrize(data)