def testShouldAutochangeHeading(self): page = Page(Path("Foo")) page.readonly = False tree = ParseTree().fromstring('<zim-tree></zim-tree>') tree.set_heading("Foo") page.set_parsetree(tree) self.assertTrue(page.heading_matches_pagename()) tree.set_heading("Bar") page.set_parsetree(tree) self.assertFalse(page.heading_matches_pagename())
def testRenamePageDialogWithHeadingChanges(self): '''Test RenamePageDialog's heading auto-change option depending on whether we have a changed heading or not. ''' tree = ParseTree().fromstring('<zim-tree></zim-tree>') tree.set_heading("bar") self.ui.page = Page(Path("Test:foo:bar"), parsetree=tree) self.ui.notebook.get_page = lambda path: self.ui.page dialog = zim.gui.RenamePageDialog(self.ui, path=Path("Test:foo:bar")) self.assertTrue(dialog.form['head']) tree.set_heading("different") dialog = zim.gui.RenamePageDialog(self.ui, path=Path("Test:foo:bar")) self.assertFalse(dialog.form['head'])
def testShouldAutochangeHeading(self): from zim.newfs.mock import MockFile, MockFolder file = MockFile('/mock/test/page.txt') folder = MockFile('/mock/test/page/') page = Page(Path('Foo'), False, file, folder) tree = ParseTree().fromstring('<zim-tree></zim-tree>') tree.set_heading("Foo") page.set_parsetree(tree) self.assertTrue(page.heading_matches_pagename()) tree.set_heading("Bar") page.set_parsetree(tree) self.assertFalse(page.heading_matches_pagename())
def testRenamePageDialogWithHeadingChanges(self): '''Test RenamePageDialog's heading auto-change option depending on whether we have a changed heading or not. ''' from zim.newfs.mock import MockFile, MockFolder file = MockFile('/mock/test/page.txt') folder = MockFile('/mock/test/page/') page = Page(Path("Test:foo:bar"), False, file, folder) tree = ParseTree().fromstring('<zim-tree></zim-tree>') tree.set_heading("bar") page.set_parsetree(tree) self.ui.page = page self.ui.notebook.get_page = lambda path: self.ui.page dialog = zim.gui.RenamePageDialog(self.ui, path=Path("Test:foo:bar")) self.assertTrue(dialog.form['head']) tree.set_heading("different") dialog = zim.gui.RenamePageDialog(self.ui, path=Path("Test:foo:bar")) self.assertFalse(dialog.form['head'])