def testRemoveTemplate(self): dialog = TemplateEditorDialog(None) select_by_name(dialog.view, 'foo_test') file = LocalFile(XDG_DATA_HOME.file('zim/templates/html/foo_test.html').path) self.assertTrue(file.exists()) dialog.on_delete() self.assertFalse(file.exists())
def testBrowseTemplates(self): dialog = TemplateEditorDialog(None) def open_folder(args): got = LocalFolder(args[-1]) want = LocalFolder(XDG_DATA_HOME.subdir('zim/templates').path) self.assertEqual(got, want) with tests.ApplicationContext(open_folder): dialog.on_browse()
def testViewTemplate(self): dialog = TemplateEditorDialog(None) select_by_name(dialog.view, 'foo_test') def open_file(args): got = LocalFile(args[-1]) want = LocalFile(XDG_DATA_HOME.file('zim/templates/html/foo_test.html').path) self.assertEqual(got, want) with tests.ApplicationContext(open_file): dialog.on_view()
def testCopyTemplate(self): dialog = TemplateEditorDialog(None) select_by_name(dialog.view, 'foo_test') def do_copy(dialog): dialog.set_input(name='new_foo_test') dialog.assert_response_ok() with tests.DialogContext(do_copy): dialog.on_copy() file = LocalFile(XDG_DATA_HOME.file('zim/templates/html/new_foo_test.html').path) self.assertTrue(file.exists())
def testTemplateEditorDialog(self): from zim.gui.templateeditordialog import TemplateEditorDialog dialog = TemplateEditorDialog(self.ui) # TODO what to test here ?? dialog.assert_response_ok()
def show_templateeditor(self): '''Menu action to show the L{TemplateEditorDialog}''' from zim.gui.templateeditordialog import TemplateEditorDialog TemplateEditorDialog(self.widget).run()
def testTemplateList(self): dialog = TemplateEditorDialog(None) model = dialog.view.get_model() self.assertIn('foo_test', [r[BASENAME_COL] for r in list_all(model)])