def testDisabledPlugins(self): # Добавим плагин TestEmpty1 в черный список self.config.disabledPlugins.value = [u"TestEmpty1"] dirlist = [u"../test/plugins/testempty1", u"../test/plugins/testempty2", u"../test/plugins/testwikicommand"] loader = PluginsLoader(Application) loader.load(dirlist) self.assertEqual(len(loader), 2) self.assertEqual(loader[u"TestEmpty2"].name, u"TestEmpty2") self.assertEqual(loader[u"TestEmpty2"].version, u"0.1") self.assertEqual(loader[u"TestEmpty2"].description, u"This plugin is empty") self.assertEqual(loader[u"TestWikiCommand"].name, u"TestWikiCommand") self.assertEqual(loader[u"TestWikiCommand"].version, u"0.1") self.assertEqual(len(loader.disabledPlugins), 1) self.assertEqual(loader.disabledPlugins[u"TestEmpty1"].name, u"TestEmpty1") self.assertEqual( loader.disabledPlugins[u"TestEmpty1"].version, u"0.1" ) self.assertEqual(loader.disabledPlugins[u"TestEmpty1"].description, u"This plugin is empty")
def testLoadInvalid (self): dirlist = [u"../plugins/testinvalid", # Нет такой директории u"../plugins/testinvalid1", u"../plugins/testinvalid2", u"../plugins/testinvalid3", u"../plugins/testinvalid4", u"../plugins/testinvalid5", u"../plugins/testinvalid6", u"../plugins/testinvalid7", u"../plugins/testempty1", u"../plugins/testempty2", u"../plugins/testempty2", # Ссылка на плагин testempty2 повторяется еще раз u"../plugins/testwikicommand"] loader = PluginsLoader(Application) loader.enableOutput = False loader.load (dirlist) self.assertEqual (len (loader), 3) self.assertEqual (loader[u"TestEmpty1"].name, u"TestEmpty1") self.assertEqual (loader[u"TestEmpty1"].version, u"0.1") self.assertEqual (loader[u"TestEmpty1"].description, u"This plugin is empty") self.assertEqual (loader[u"TestEmpty2"].name, u"TestEmpty2") self.assertEqual (loader[u"TestEmpty2"].version, u"0.1") self.assertEqual (loader[u"TestEmpty2"].description, u"This plugin is empty") self.assertEqual (loader[u"TestWikiCommand"].name, u"TestWikiCommand") self.assertEqual (loader[u"TestWikiCommand"].version, u"0.1")
class PluginNameTest (unittest.TestCase): """Тесты плагина PluginName""" def setUp (self): self.__createWiki() dirlist = [u"../plugins/pluginname"] self.loader = PluginsLoader(Application) self.loader.load (dirlist) def tearDown (self): removeDir (self.path) self.loader.clear() def __createWiki (self): # Здесь будет создаваться вики self.path = u"../test/testwiki" removeDir (self.path) self.rootwiki = WikiDocument.create (self.path) WikiPageFactory().create (self.rootwiki, u"Страница 1", []) self.testPage = self.rootwiki[u"Страница 1"] def testPluginLoad (self): self.assertEqual (len (self.loader), 1)
def testLoad(self): dirlist = [u"../test/plugins/testempty1", u"../test/plugins/testempty2", u"../test/plugins/testempty2"] loader = PluginsLoader(Application) loader.load(dirlist) self.assertEqual(len(loader), 2) self.assertEqual(loader[u"TestEmpty1"].name, u"TestEmpty1") self.assertEqual(loader[u"TestEmpty1"].version, u"0.1") self.assertEqual(loader[u"TestEmpty1"].description, u"This plugin is empty") self.assertEqual(loader[u"TestEmpty1"].application, Application) self.assertEqual(loader[u"TestEmpty2"].name, u"TestEmpty2") self.assertEqual(loader[u"TestEmpty2"].version, u"0.1") self.assertEqual(loader[u"TestEmpty2"].description, u"This plugin is empty") # Проверим, как работает итерация for plugin in loader: self.assertTrue(plugin == loader[u"TestEmpty1"] or plugin == loader[u"TestEmpty2"]) loader.clear() self.assertEqual(len(loader), 0)
class TemplateTest (unittest.TestCase): """Тесты плагина Template""" def setUp (self): self.__createWiki() dirlist = [u"../plugins/template"] self.loader = PluginsLoader(Application) self.loader.load (dirlist) def tearDown (self): removeDir (self.path) self.loader.clear() def __createWiki (self): # Здесь будет создаваться вики self.path = mkdtemp (prefix=u'Абырвалг абыр') self.wikiroot = WikiDocument.create (self.path) WikiPageFactory().create (self.wikiroot, u"Страница 1", []) self.testPage = self.wikiroot[u"Страница 1"] def testPluginLoad (self): self.assertEqual (len (self.loader), 1)
def testLoadInvalid_04(self): dirlist = [u"../test/plugins/testoutdated"] loader = PluginsLoader(Application) loader.enableOutput = False loader.load(dirlist) self.assertEqual(len(loader), 0) self.assertEqual(len(loader.invalidPlugins), 1)
def setUp(self): self.__createWiki() dirlist = [u"../plugins/testwikicommand"] loader = PluginsLoader(Application) loader.load (dirlist) factory = ParserFactory() self.parser = factory.make (self.testPage, Application.config)
class LinkCreatorTest (unittest.TestCase): def setUp(self): dirlist = [u"../plugins/markdown"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) def test_empty_01(self): from markdown.links.linkcreator import LinkCreator creator = LinkCreator() link, reference = creator.create(u'', u'', u'') link_right = u'[]()' self.assertEqual(link, link_right) self.assertIsNone(reference) def test_empty_02(self): from markdown.links.linkcreator import LinkCreator creator = LinkCreator() link, reference = creator.create(u' ', u'', u'') link_right = u'[]()' self.assertEqual(link, link_right) self.assertIsNone(reference) def test_empty_03(self): from markdown.links.linkcreator import LinkCreator creator = LinkCreator() link, reference = creator.create(u'', u' ', u'') link_right = u'[ ]()' self.assertEqual(link, link_right) self.assertIsNone(reference) def test_link_01(self): from markdown.links.linkcreator import LinkCreator creator = LinkCreator() link, reference = creator.create(u'http://jenyay.net', u'Комментарий', u'') link_right = u'[Комментарий](http://jenyay.net)' self.assertEqual(link, link_right) self.assertIsNone(reference) def test_title_01(self): from markdown.links.linkcreator import LinkCreator creator = LinkCreator() link, reference = creator.create(u'http://jenyay.net', u'Комментарий', u'Заголовок') link_right = u'[Комментарий](http://jenyay.net "Заголовок")' self.assertEqual(link, link_right) self.assertIsNone(reference)
def testLoadInvalid_02(self): dirlist = [u"../test/plugins/testinvalid1"] loader = PluginsLoader(Application) loader.enableOutput = False loader.load(dirlist) self.assertEqual(len(loader), 0) self.assertEqual(len(loader.invalidPlugins), 1) self.assertIn(u'TypeError', loader.invalidPlugins[0].description)
class SnippetsVarDialogTest(BaseMainWndTest): def setUp(self): BaseMainWndTest.setUp(self) mainWnd = Application.mainWindow plugins_dir = [u"../plugins/snippets"] self.loader = PluginsLoader(Application) self.loader.load(plugins_dir) from snippets.gui.variablesdialog import VariablesDialog self._dialog = VariablesDialog(mainWnd) def tearDown(self): self._dialog.Destroy() self.loader.clear() BaseMainWndTest.tearDown(self) def test_empty(self): variables = self._dialog.getVarDict() self.assertEqual(variables, {}) def test_single_empty(self): self._dialog.addStringVariable(u'test') variables = self._dialog.getVarDict() self.assertEqual(variables, {u'test': u''}) def test_single(self): self._dialog.addStringVariable(u'test') self._dialog.setStringVariable(u'test', u'Проверка') variables = self._dialog.getVarDict() self.assertEqual(variables, {u'test': u'Проверка'}) def test_two_items(self): self._dialog.addStringVariable(u'test_1') self._dialog.addStringVariable(u'test_2') self._dialog.setStringVariable(u'test_1', u'Проверка_1') self._dialog.setStringVariable(u'test_2', u'Проверка_2') variables = self._dialog.getVarDict() self.assertEqual(variables, {u'test_1': u'Проверка_1', u'test_2': u'Проверка_2'}) def test_no_item(self): self.assertRaises(KeyError, self._dialog.setStringVariable, u'test', u'test')
class SnippetsVarDialogTest(unittest.TestCase, BaseOutWikerGUIMixin): def setUp(self): self.initApplication() mainWnd = self.application.mainWindow plugins_dir = ["../plugins/snippets"] self.loader = PluginsLoader(self.application) self.loader.load(plugins_dir) from snippets.gui.variablesdialog import VariablesDialog self._dialog = VariablesDialog(mainWnd) def tearDown(self): self._dialog.Destroy() self.loader.clear() self.destroyApplication() def test_empty(self): variables = self._dialog.getVarDict() self.assertEqual(variables, {}) def test_single_empty(self): self._dialog.addStringVariable('test') variables = self._dialog.getVarDict() self.assertEqual(variables, {'test': ''}) def test_single(self): self._dialog.addStringVariable('test') self._dialog.setStringVariable('test', 'Проверка') variables = self._dialog.getVarDict() self.assertEqual(variables, {'test': 'Проверка'}) def test_two_items(self): self._dialog.addStringVariable('test_1') self._dialog.addStringVariable('test_2') self._dialog.setStringVariable('test_1', 'Проверка_1') self._dialog.setStringVariable('test_2', 'Проверка_2') variables = self._dialog.getVarDict() self.assertEqual(variables, {'test_1': 'Проверка_1', 'test_2': 'Проверка_2'}) def test_no_item(self): self.assertRaises(KeyError, self._dialog.setStringVariable, 'test', 'test')
def setUp(self): self.initApplication() self.wikiroot = self.createWiki() dirlist = ["plugins/diagrammer"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) from diagrammer.gui.insertdiagramdialog import ( InsertDiagramDialog, InsertDiagramController ) self._dlg = InsertDiagramDialog(None) self._controller = InsertDiagramController(self._dlg) Tester.dialogTester.clear()
def setUp(self): self.initApplication() self.wikiroot = self.createWiki() self.__pluginname = "Statistics" dirlist = ["plugins/statistics"] self.loader = PluginsLoader(self.application) self.loader.load(dirlist) filesPath = "testdata/samplefiles/" self.files = ["accept.png", "add.png", "anchor.png", "dir"] self.fullFilesPath = [ os.path.join(filesPath, fname) for fname in self.files ]
def setUp(self): self.initApplication() dirlist = ["../plugins/tableofcontents"] self.loader = PluginsLoader(self.application) self.loader.load(dirlist)
def setUp (self): BaseMainWndTest.setUp (self) self.filesPath = u"../test/samplefiles/" self.__createWiki() dirlist = [u"../plugins/changepageuid"] self._loader = PluginsLoader(Application) self._loader.load (dirlist) from changepageuid.dialog import ChangeUidDialog self._dlg = ChangeUidDialog (Application.mainWindow) Tester.dialogTester.clear() self.testPage = self.wikiroot[u"Страница 1"]
def setUp(self): dirlist = [u"../plugins/datagraph"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) self._dataFile = NamedTemporaryFile(delete=False)
def setUp(self): dirlist = ["../plugins/datagraph"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) self._dataFile = NamedTemporaryFile(mode='w', delete=False, encoding='utf8')
def setUp (self): super (TestPageTest, self).setUp () self.dirlist = [u"../test/plugins/testpage"] self.loader = PluginsLoader(Application) self.loader.load (self.dirlist)
def setUp(self): self.initApplication() plugins_dirs = ["../plugins/pagetypecolor"] self.loader = PluginsLoader(self.application) self.loader.load(plugins_dirs) self._clearConfig()
def setUp(self): self.__pluginname = u"Source" self.__createWiki() dirlist = [u"../plugins/source"] # Путь, где лежат примеры исходников в разных кодировках self.samplefilesPath = u"../test/samplefiles/sources" # Пример программы self.pythonSource = u'''import os # Комментарий def hello (count): """ Hello world """ for i in range (10): print "Hello world!!!" ''' self.loader = PluginsLoader(Application) self.loader.load (dirlist) self.config = self.loader[self.__pluginname].config self.config.tabWidth.value = 4 self.config.defaultLanguage.remove_option() Application.config.remove_section (self.config.section) self.factory = ParserFactory() self.parser = self.factory.make (self.testPage, Application.config)
def setUp (self): self.__createWiki() dirlist = [u"../plugins/template"] self.loader = PluginsLoader(Application) self.loader.load (dirlist)
def setUp(self): self.initApplication() dirlist = ["../plugins/snippets"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) self._dir_snippets = mkdtemp('outwiker_snippets')
def setUp (self): self.plugindirlist = [u'../plugins/webpage'] self._staticDirName = u'__download' self._tempDir = mkdtemp (prefix=u'Абырвалг абыр') self.loader = PluginsLoader(Application) self.loader.load (self.plugindirlist)
class SnippetsVarPanelTest(BaseMainWndTest): def setUp(self): BaseMainWndTest.setUp(self) mainWnd = Application.mainWindow plugins_dir = [u"../plugins/snippets"] self.loader = PluginsLoader(Application) self.loader.load(plugins_dir) from snippets.gui.variablesdialog import VaraiblesPanel self._panel = VaraiblesPanel(mainWnd) def tearDown(self): self.loader.clear() BaseMainWndTest.tearDown(self) def test_empty(self): variables = self._panel.getVarDict() self.assertEqual(variables, {}) def test_single_empty(self): self._panel.addStringVariable(u'test') variables = self._panel.getVarDict() self.assertEqual(variables, {u'test': u''}) def test_single(self): self._panel.addStringVariable(u'test') self._panel.setVarString(u'test', u'Проверка') variables = self._panel.getVarDict() self.assertEqual(variables, {u'test': u'Проверка'}) def test_two_items(self): self._panel.addStringVariable(u'test_1') self._panel.addStringVariable(u'test_2') self._panel.setVarString(u'test_1', u'Проверка_1') self._panel.setVarString(u'test_2', u'Проверка_2') variables = self._panel.getVarDict() self.assertEqual(variables, { u'test_1': u'Проверка_1', u'test_2': u'Проверка_2' }) def test_no_item(self): self.assertRaises(KeyError, self._panel.setVarString, u'test', u'test')
class WikiCounterCommandTest (unittest.TestCase): def setUp(self): self.encoding = "utf8" self.filesPath = u"../test/samplefiles/" self.__createWiki() dirlist = [u"../plugins/testcounter"] self.loader = PluginsLoader(Application) self.loader.load (dirlist) self.factory = ParserFactory() self.parser = self.factory.make (self.testPage, Application.config) def __createWiki (self): # Здесь будет создаваться вики self.path = u"../test/testwiki" removeWiki (self.path) self.rootwiki = WikiDocument.create (self.path) WikiPageFactory.create (self.rootwiki, u"Страница 1", []) self.testPage = self.rootwiki[u"Страница 1"] def tearDown(self): removeWiki (self.path) def testPluginLoad (self): self.assertEqual ( len (self.loader), 1) def testCounter (self): text = u"(:counter:) (:counter:)" validResult = u"1 2" result = self.parser.toHtml (text) self.assertEqual (result, validResult) # Проверим, что для нового парсера счетчик сбрасывается parser2 = self.factory.make (self.testPage, Application.config) result2 = parser2.toHtml (text) self.assertEqual (result2, validResult)
class SnippetsVarPanelTest(unittest.TestCase, BaseOutWikerGUIMixin): def setUp(self): self.initApplication() mainWnd = self.application.mainWindow plugins_dir = ["plugins/snippets"] self.loader = PluginsLoader(self.application) self.loader.load(plugins_dir) from snippets.gui.variablesdialog import VaraiblesPanel self._panel = VaraiblesPanel(mainWnd) def tearDown(self): self.loader.clear() self.destroyApplication() def test_empty(self): variables = self._panel.getVarDict() self.assertEqual(variables, {}) def test_single_empty(self): self._panel.addStringVariable('test') variables = self._panel.getVarDict() self.assertEqual(variables, {'test': ''}) def test_single(self): self._panel.addStringVariable('test') self._panel.setVarString('test', 'Проверка') variables = self._panel.getVarDict() self.assertEqual(variables, {'test': 'Проверка'}) def test_two_items(self): self._panel.addStringVariable('test_1') self._panel.addStringVariable('test_2') self._panel.setVarString('test_1', 'Проверка_1') self._panel.setVarString('test_2', 'Проверка_2') variables = self._panel.getVarDict() self.assertEqual(variables, { 'test_1': 'Проверка_1', 'test_2': 'Проверка_2' }) def test_no_item(self): self.assertRaises(KeyError, self._panel.setVarString, 'test', 'test')
def setUp(self): BaseMainWndTest.setUp(self) self.__pluginname = u"Livejournal" self.__createWiki() self.testPage = self.wikiroot[u"Страница 1"] dirlist = [u"../plugins/livejournal"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) from livejournal.ljconfig import LJConfig LJConfig(Application.config).users.value = [] LJConfig(Application.config).communities.value = []
def setUp(self): self.initApplication() self.wikiroot = self.createWiki() self.dirlist = ["../test/plugins/testpage"] self.loader = PluginsLoader(self.application) self.loader.load(self.dirlist)
def setUp(self): dirlist = [u"../plugins/htmlformatter"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) factory = HtmlImproverFactory(Application) self.improver = factory["pimprover"]
def setUp(self): self.initApplication() self.wikiroot = self.createWiki() self.testPage = WikiPageFactory().create(self.wikiroot, "Страница 1", []) self.maxDiff = None self.filesPath = "testdata/samplefiles/" dirlist = ["plugins/thumbgallery"] self.loader = PluginsLoader(self.application) self.loader.load(dirlist) self.factory = ParserFactory() self.parser = self.factory.make(self.testPage, self.application.config)
def setUp(self): self.initApplication() self.dirlist = ["../plugins/webpage"] self.path = mkdtemp(prefix='OutWiker_Абырвалг абырвалг_' + str(self.__class__.__name__)) self.loader = PluginsLoader(self.application) self.loader.load(self.dirlist)
class LangListTest(unittest.TestCase, BaseOutWikerGUIMixin): def setUp(self): self.initApplication() dirlist = ["../plugins/source"] self.loader = PluginsLoader(self.application) self.loader.load(dirlist) from source.langlist import LangList self._langlist = LangList() def tearDown(self): self.loader.clear() self.destroyApplication() def test_all(self): self.assertIn('Ada', self._langlist.allNames()) self.assertIn('HTML + Angular2', self._langlist.allNames()) self.assertIn('1S', self._langlist.allNames()) def test_getAllDesignations(self): self.assertEqual(self._langlist.getAllDesignations('Ada'), ('ada', 'ada95', 'ada2005')) self.assertEqual(self._langlist.getAllDesignations('ANTLR'), ('antlr',)) def test_getAllDesignations_invalid(self): self.assertIsNone(self._langlist.getAllDesignations('adsfa asdfadf')) def test_getDesignation(self): self.assertEqual(self._langlist.getDesignation('Ada'), 'ada') self.assertEqual(self._langlist.getDesignation('ANTLR'), 'antlr') self.assertEqual(self._langlist.getDesignation('C++'), 'cpp') def test_getDesignation_invalid(self): self.assertIsNone(self._langlist.getDesignation('adfasdfaf')) def test_getLangName(self): self.assertEqual(self._langlist.getLangName('ada'), 'Ada') self.assertEqual(self._langlist.getLangName('ada2005'), 'Ada') self.assertEqual(self._langlist.getLangName('html+spitfire'), 'HTML+Cheetah') def test_getLangName_invalid(self): self.assertIsNone(self._langlist.getLangName('asdfadsfads'))
def setUp(self): BaseMainWndTest.setUp (self) self.__createWiki () dirlist = [self.getPluginDir()] self.loader = PluginsLoader(Application) self.loader.load (dirlist)
def testOnOffPlugins2 (self): # Тест на включение/выключение плагинов dirlist = [u"../plugins/testempty1", u"../plugins/testempty2", u"../plugins/testwikicommand"] loader = PluginsLoader(Application) loader.load (dirlist) self.assertEqual (len (loader), 3) self.assertEqual (len (loader.disabledPlugins), 0) # Обновим черный список без изменений loader.updateDisableList() self.assertEqual (len (loader), 3) self.assertEqual (len (loader.disabledPlugins), 0)
def setUp(self): self.initApplication() self.wikiroot = self.createWiki() self.testPage = WikiPageFactory().create(self.wikiroot, "Страница 1", []) self.testPage2 = WikiPageFactory().create(self.wikiroot, "Страница 2", []) dirlist = ["plugins/hackpage"] self._loader = PluginsLoader(self.application) self._loader.load(dirlist) Tester.dialogTester.clear()
def setUp (self): BaseMainWndTest.setUp (self) self.filesPath = u"../test/samplefiles/" WikiPageFactory().create (self.wikiroot, u"Страница 1", []) dirlist = [u"../plugins/counter"] self._loader = PluginsLoader(Application) self._loader.load (dirlist) from counter.insertdialog import InsertDialog self._dlg = InsertDialog (Application.mainWindow) Tester.dialogTester.clear() Tester.dialogTester.appendOk() self.testPage = self.wikiroot[u"Страница 1"]
def setUp(self): self.outputdir = "../test/temp" self.pluginname = u"Export2Html" self.path = u"../test/samplewiki" self.root = WikiDocument.load(self.path) dirlist = [u"../plugins/export2html"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) removeDir(self.outputdir) os.mkdir(self.outputdir) Application.wikiroot = None
class LangListTest(unittest.TestCase, BaseOutWikerGUIMixin): def setUp(self): self.initApplication() dirlist = ["plugins/source"] self.loader = PluginsLoader(self.application) self.loader.load(dirlist) from source.langlist import LangList self._langlist = LangList() def tearDown(self): self.loader.clear() self.destroyApplication() def test_all(self): self.assertIn('Ada', self._langlist.allNames()) self.assertIn('HTML + Angular2', self._langlist.allNames()) self.assertIn('1S', self._langlist.allNames()) def test_getAllDesignations(self): self.assertEqual(self._langlist.getAllDesignations('Ada'), ('ada', 'ada95', 'ada2005')) self.assertEqual(self._langlist.getAllDesignations('ANTLR'), ('antlr', )) def test_getAllDesignations_invalid(self): self.assertIsNone(self._langlist.getAllDesignations('adsfa asdfadf')) def test_getDesignation(self): self.assertEqual(self._langlist.getDesignation('Ada'), 'ada') self.assertEqual(self._langlist.getDesignation('ANTLR'), 'antlr') self.assertEqual(self._langlist.getDesignation('C++'), 'cpp') def test_getDesignation_invalid(self): self.assertIsNone(self._langlist.getDesignation('adfasdfaf')) def test_getLangName(self): self.assertEqual(self._langlist.getLangName('ada'), 'Ada') self.assertEqual(self._langlist.getLangName('ada2005'), 'Ada') self.assertEqual(self._langlist.getLangName('html+spitfire'), 'HTML+Cheetah') def test_getLangName_invalid(self): self.assertIsNone(self._langlist.getLangName('asdfadsfads'))
class SnippetsVarPanelTest(BaseMainWndTest): def setUp(self): BaseMainWndTest.setUp(self) mainWnd = Application.mainWindow plugins_dir = [u"../plugins/snippets"] self.loader = PluginsLoader(Application) self.loader.load(plugins_dir) from snippets.gui.variablesdialog import VaraiblesPanel self._panel = VaraiblesPanel(mainWnd) def tearDown(self): self.loader.clear() BaseMainWndTest.tearDown(self) def test_empty(self): variables = self._panel.getVarDict() self.assertEqual(variables, {}) def test_single_empty(self): self._panel.addStringVariable(u"test") variables = self._panel.getVarDict() self.assertEqual(variables, {u"test": u""}) def test_single(self): self._panel.addStringVariable(u"test") self._panel.setVarString(u"test", u"Проверка") variables = self._panel.getVarDict() self.assertEqual(variables, {u"test": u"Проверка"}) def test_two_items(self): self._panel.addStringVariable(u"test_1") self._panel.addStringVariable(u"test_2") self._panel.setVarString(u"test_1", u"Проверка_1") self._panel.setVarString(u"test_2", u"Проверка_2") variables = self._panel.getVarDict() self.assertEqual(variables, {u"test_1": u"Проверка_1", u"test_2": u"Проверка_2"}) def test_no_item(self): self.assertRaises(KeyError, self._panel.setVarString, u"test", u"test")
def setUp(self): self.initApplication('ru_RU') self.__createWiki() dirlist = ["../plugins/organizer"] self.loader = PluginsLoader(Application) self.loader.load(dirlist)
def setUp(self): self.initApplication() self.wikiroot = self.createWiki() self.__pluginname = "Livejournal" self.__createWiki() self.testPage = self.wikiroot["Страница 1"] dirlist = ["plugins/livejournal"] self.loader = PluginsLoader(self.application) self.loader.load(dirlist) from livejournal.ljconfig import LJConfig LJConfig(self.application.config).users.value = [] LJConfig(self.application.config).communities.value = [] Tester.dialogTester.clear()
def setUp(self): self.initApplication() self.wikiroot = self.createWiki() self.__createWiki() dirlist = [self.getPluginDir()] self.loader = PluginsLoader(self.application) self.loader.load(dirlist)
def setUp(self): self.initApplication() self.wikiroot = self.createWiki() self.filesPath = "testdata/samplefiles/" WikiPageFactory().create(self.wikiroot, "Страница 1", []) dirlist = ["plugins/counter"] self._loader = PluginsLoader(self.application) self._loader.load(dirlist) from counter.insertdialog import InsertDialog self._dlg = InsertDialog(self.application.mainWindow) Tester.dialogTester.clear() Tester.dialogTester.appendOk() self.testPage = self.wikiroot["Страница 1"]
def setUp(self): self.__pluginname = u"Source" self.__createWiki() dirlist = [u"../plugins/source"] self._stylesCount = 26 self.loader = PluginsLoader(Application) self.loader.load(dirlist) self.config = self.loader[self.__pluginname].config self._clearConfig(self.config) from source.insertdialogcontroller import InsertDialogController self.dialog = FakeInsertDialog() self.controller = InsertDialogController(self.testPage, self.dialog, self.config)
def setUp(self): self.maxDiff = None self.__createWiki() self.testPage = self.wikiroot['Страница 1'] self.testPageTextPath = os.path.join(self.testPage.path, '__page.text') self.testPageHtmlPath = os.path.join( self.testPage.path, PAGE_RESULT_HTML) self.testPageAttachPath = Attachment( self.testPage).getAttachPath(False) dirlist = ['plugins/externaltools'] self.loader = PluginsLoader(Application) self.loader.load(dirlist) self.factory = ParserFactory() self.parser = self.factory.make(self.testPage, Application.config)
def setUp(self): plugins_dir = [u"../plugins/snippets"] self.loader = PluginsLoader(Application) self.loader.load(plugins_dir) self._createWiki() self._application = Application factory = ParserFactory() self.parser = factory.make(self.testPage, self._application.config) from snippets.utils import getSnippetsDir root_snippets_dir = getSnippetsDir() # snippets dir for tests self._snippets_dir = os.path.join(root_snippets_dir, u'__test_snippets') os.mkdir(self._snippets_dir)
def setUp(self): self.__pluginname = u"Source" self.__createWiki() dirlist = [u"../plugins/source"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) self.config = self.loader[self.__pluginname].config self.config.tabWidth.value = 4 self.config.defaultLanguage.remove_option() Application.config.remove_section(self.config.section) from source.insertdialogcontroller import InsertDialogController self.dialog = FakeInsertDialog() self.controller = InsertDialogController(self.testPage, self.dialog, self.config)
def setUp(self): self.initApplication() self.wikiroot = self.createWiki() self.testPage = WikiPageFactory().create(self.wikiroot, "Страница 1", []) plugins_dir = ["../plugins/snippets"] self.loader = PluginsLoader(self.application) self.loader.load(plugins_dir) factory = ParserFactory() self.parser = factory.make(self.testPage, self.application.config) from snippets.utils import getSnippetsDir root_snippets_dir = getSnippetsDir() # snippets dir for tests self._snippets_dir = os.path.join(root_snippets_dir, '__test_snippets') os.mkdir(self._snippets_dir)
class MarkdownPolyactionsTest(BaseEditorPolyactionsTest): """Test polyactions for Markdown pages""" def setUp(self): dirlist = [u"../plugins/markdown"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) super(MarkdownPolyactionsTest, self).setUp() def tearDown(self): self.loader.clear() super(MarkdownPolyactionsTest, self).tearDown() def _createPage(self): from markdown.markdownpage import MarkdownPageFactory return MarkdownPageFactory().create(self.wikiroot, u"Markdown-страница", []) def _getEditor(self): return Application.mainWindow.pagePanel.pageView.codeEditor
def setUp(self): self.__pluginname = u"Source" self.__createWiki() dirlist = [u"../plugins/source"] # Путь, где лежат примеры исходников в разных кодировках self.samplefilesPath = u"../test/samplefiles/sources" self.loader = PluginsLoader(Application) self.loader.load(dirlist) self.config = self.loader[self.__pluginname].config self.config.tabWidth.value = 4 self.config.defaultLanguage.remove_option() self.factory = ParserFactory() self.parser = self.factory.make(self.testPage, Application.config)
class HtmlFormatterTest(unittest.TestCase): """Тесты плагина HtmlFormatter""" def setUp(self): dirlist = [u"../plugins/htmlformatter"] self.loader = PluginsLoader(Application) self.loader.load(dirlist) def tearDown(self): self.loader.clear() def testPluginLoad(self): self.assertEqual(len(self.loader), 1) def testFactory(self): from htmlformatter.paragraphimprover import ParagraphHtmlImprover factory = HtmlImproverFactory(Application) self.assertEqual(type(factory['pimprover']), ParagraphHtmlImprover)
def setUp(self): self.__pluginname = "Source" self.initApplication() self.wikiroot = self.createWiki() self.testPage = WikiPageFactory().create(self.wikiroot, "Страница 1", []) dirlist = ["../plugins/source"] self._stylesCount = 35 self.loader = PluginsLoader(self.application) self.loader.load(dirlist) self.config = self.loader[self.__pluginname].config self._clearConfig(self.config) from source.insertdialogcontroller import InsertDialogController self.dialog = FakeInsertDialog() self.controller = InsertDialogController(self.testPage, self.dialog, self.config)
def setUp(self): self.__pluginname = "Source" self.initApplication() self.wikiroot = self.createWiki() self.testPage = WikiPageFactory().create(self.wikiroot, "Страница 1", []) dirlist = ["plugins/source"] self.loader = PluginsLoader(self.application) self.loader.load(dirlist) self.config = self.loader[self.__pluginname].config self.config.tabWidth.value = 4 self.config.defaultLanguage.remove_option() self.application.config.remove_section(self.config.section) from source.insertdialogcontroller import InsertDialogController self.dialog = FakeInsertDialog() self.controller = InsertDialogController( self.testPage, self.dialog, self.config)
def setUp(self): self.__pluginname = "Source" self.initApplication() self.wikiroot = self.createWiki() self.testPage = WikiPageFactory().create(self.wikiroot, "Страница 1", []) dirlist = ["plugins/source"] # Путь, где лежат примеры исходников в разных кодировках self.samplefilesPath = "testdata/samplefiles/sources" self.loader = PluginsLoader(self.application) self.loader.load(dirlist) self.config = self.loader[self.__pluginname].config self.config.tabWidth.value = 4 self.config.defaultLanguage.remove_option() self.factory = ParserFactory() self.parser = self.factory.make(self.testPage, self.application.config)
def testReload(self): tmp_plugin_dir = "../test/plugins/testreload" # init test shutil.copyfile('../test/plugins/testreload/testreload/testreload.v1', '../test/plugins/testreload/testreload/plugin.py') dirlist = [tmp_plugin_dir] loader = PluginsLoader(self.application) loader.load(dirlist) # pre-observation self.assertEqual(len(loader), 1) self.assertEqual(loader["TestReload"].name, "TestReload") self.assertEqual(loader["TestReload"].version, "0.1") # replace plugin file to ver 0.2 os.remove('../test/plugins/testreload/testreload/plugin.py') sleep(1) shutil.copyfile('../test/plugins/testreload/testreload/testreload.v2', '../test/plugins/testreload/testreload/plugin.py') # observation loader.reload("TestReload") self.assertEqual(len(loader), 1) self.assertEqual(loader["TestReload"].name, "TestReload") self.assertEqual(loader["TestReload"].version, "0.2") # restore os.remove('../test/plugins/testreload/testreload/plugin.py')
def testLoad(self): dirlist = [ u"../plugins/testempty1", u"../plugins/testempty2", u"../plugins/testempty2" ] loader = PluginsLoader(Application) loader.load(dirlist) self.assertEqual(len(loader), 2) self.assertEqual(loader[u"TestEmpty1"].name, u"TestEmpty1") self.assertEqual(loader[u"TestEmpty1"].version, u"0.1") self.assertEqual(loader[u"TestEmpty1"].description, u"This plugin is empty") self.assertEqual(loader[u"TestEmpty1"].application, Application) self.assertEqual(loader[u"TestEmpty2"].name, u"TestEmpty2") self.assertEqual(loader[u"TestEmpty2"].version, u"0.1") self.assertEqual(loader[u"TestEmpty2"].description, u"This plugin is empty") # Проверим, как работает итерация for plugin in loader: self.assertTrue(plugin == loader[u"TestEmpty1"] or plugin == loader[u"TestEmpty2"]) loader.clear() self.assertEqual(len(loader), 0)
def testLoadInvalid_01(self): dirlist = [ "testdata/plugins/testinvalid", # Нет такой директории "testdata/plugins/testinvalid1", "testdata/plugins/testinvalid2", "testdata/plugins/testinvalid4", "testdata/plugins/testinvalid5", "testdata/plugins/testinvalid6", "testdata/plugins/testinvalid7", # no plugin.py file in the packages "testdata/plugins/testinvalid8", "testdata/plugins/testempty1", "testdata/plugins/testempty2", # Ссылка на плагин testempty2 повторяется еще раз "testdata/plugins/testempty2", "testdata/plugins/testwikicommand", "testdata/plugins/testoutdated", "testdata/plugins/testfromfuture", ] loader = PluginsLoader(self.application) loader.enableOutput = False loader.load(dirlist) self.assertEqual(len(loader), 3) self.assertEqual(loader["TestEmpty1"].name, "TestEmpty1") self.assertEqual(loader["TestEmpty1"].version, "0.1") self.assertEqual(loader["TestEmpty1"].description, "This plugin is empty") self.assertEqual(loader["TestEmpty2"].name, "TestEmpty2") self.assertEqual(loader["TestEmpty2"].version, "0.1") self.assertEqual(loader["TestEmpty2"].description, "This plugin is empty") self.assertEqual(loader["TestWikiCommand"].name, "TestWikiCommand") self.assertEqual(loader["TestWikiCommand"].version, "0.1")
def testDisable(self): dirlist = ["../test/plugins/testempty1", "../test/plugins/testempty2"] loader = PluginsLoader(self.application) loader.load(dirlist) self.assertEqual(len(loader.loadedPlugins), 2) loader.disable('TestEmpty1') self.assertEqual(len(loader.disabledPlugins), 1)
def testEnable(self): self.config.disabledPlugins.value = ["TestEmpty1", "TestEmpty2"] dirlist = ["../test/plugins/testempty1", "../test/plugins/testempty2"] loader = PluginsLoader(self.application) loader.load(dirlist) self.assertEqual(len(loader.disabledPlugins), 2) loader.enable('TestEmpty1') self.assertEqual(len(loader), 1) self.assertEqual(len(loader.disabledPlugins), 1) loader.enable('TestEmpty2') loader.enable('TestEmpty2') self.assertEqual(len(loader), 2) self.assertEqual(len(loader.disabledPlugins), 0)
def testOnOffPlugins6(self): # Тест на включение/выключение плагинов dirlist = [u"../test/plugins/testempty1", u"../test/plugins/testempty2", u"../test/plugins/testwikicommand"] loader = PluginsLoader(Application) loader.load(dirlist) self.assertEqual(len(loader), 3) self.assertEqual(len(loader.disabledPlugins), 0) self.assertTrue(loader[u"TestEmpty1"].enabled) # Отключим плагин TestEmpty1 self.config.disabledPlugins.value = [u"TestEmpty1"] loader.updateDisableList() self.assertFalse(loader.disabledPlugins[u"TestEmpty1"].enabled) # Опять включим плагин TestEmpty1 self.config.disabledPlugins.value = [] loader.updateDisableList() self.assertTrue(loader[u"TestEmpty1"].enabled)