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 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 _db_recover(self):
     assert not self.dbpath == ':memory:'
     file = LocalFile(self.dbpath)
     if file.exists():
         logger.warning('Overwriting possibly corrupt database: %s',
                        self.dbpath)
     try:
         file.remove(cleanup=False)
     except:
         logger.error(
             'Could not access database file, running in-memory database')
         self.dbpath = ':memory:'
     finally:
         self._db = sqlite3.Connection(self.dbpath)
         self._db.row_factory = sqlite3.Row
         self._db_init()