コード例 #1
0
    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")
コード例 #2
0
ファイル: loader.py プロジェクト: LihMeh/outwiker
    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")
コード例 #3
0
ファイル: test_plugin.py プロジェクト: LihMeh/outwiker
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)
コード例 #4
0
    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)
コード例 #5
0
ファイル: template.py プロジェクト: LihMeh/outwiker
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)
コード例 #6
0
    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)
コード例 #7
0
ファイル: testwikicommand.py プロジェクト: qyqx/outwiker
    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)
コード例 #8
0
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)
コード例 #9
0
    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)
コード例 #10
0
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')
コード例 #11
0
ファイル: test_vardialog.py プロジェクト: Jenyay/outwiker
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')
コード例 #12
0
    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()
コード例 #13
0
    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
        ]
コード例 #14
0
ファイル: test_toc_wikimaker.py プロジェクト: Jenyay/outwiker
    def setUp(self):
        self.initApplication()

        dirlist = ["../plugins/tableofcontents"]

        self.loader = PluginsLoader(self.application)
        self.loader.load(dirlist)
コード例 #15
0
    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"]
コード例 #16
0
ファイル: datasources.py プロジェクト: theoden-dd/outwiker
    def setUp(self):
        dirlist = [u"../plugins/datagraph"]

        self.loader = PluginsLoader(Application)
        self.loader.load(dirlist)

        self._dataFile = NamedTemporaryFile(delete=False)
コード例 #17
0
ファイル: test_datasources.py プロジェクト: Jenyay/outwiker
    def setUp(self):
        dirlist = ["../plugins/datagraph"]

        self.loader = PluginsLoader(Application)
        self.loader.load(dirlist)

        self._dataFile = NamedTemporaryFile(mode='w', delete=False, encoding='utf8')
コード例 #18
0
    def setUp (self):
        super (TestPageTest, self).setUp ()

        self.dirlist = [u"../test/plugins/testpage"]

        self.loader = PluginsLoader(Application)
        self.loader.load (self.dirlist)
コード例 #19
0
ファイル: test_colorslist.py プロジェクト: Jenyay/outwiker
    def setUp(self):
        self.initApplication()
        plugins_dirs = ["../plugins/pagetypecolor"]

        self.loader = PluginsLoader(self.application)
        self.loader.load(plugins_dirs)
        self._clearConfig()
コード例 #20
0
ファイル: sourcestyle.py プロジェクト: LihMeh/outwiker
    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)
コード例 #21
0
ファイル: template.py プロジェクト: LihMeh/outwiker
    def setUp (self):
        self.__createWiki()

        dirlist = [u"../plugins/template"]

        self.loader = PluginsLoader(Application)
        self.loader.load (dirlist)
コード例 #22
0
    def setUp(self):
        self.initApplication()
        dirlist = ["../plugins/snippets"]

        self.loader = PluginsLoader(Application)
        self.loader.load(dirlist)
        self._dir_snippets = mkdtemp('outwiker_snippets')
コード例 #23
0
    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)
コード例 #24
0
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')
コード例 #25
0
ファイル: wikicommandcounter.py プロジェクト: qyqx/outwiker
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)
コード例 #26
0
ファイル: test_varpanel.py プロジェクト: Jenyay/outwiker
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')
コード例 #27
0
ファイル: test_livejournal.py プロジェクト: sarutobi/outwiker
    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 = []
コード例 #28
0
    def setUp(self):
        self.initApplication()
        self.wikiroot = self.createWiki()

        self.dirlist = ["../test/plugins/testpage"]

        self.loader = PluginsLoader(self.application)
        self.loader.load(self.dirlist)
コード例 #29
0
ファイル: htmlimproverp.py プロジェクト: theoden-dd/outwiker
    def setUp(self):
        dirlist = [u"../plugins/htmlformatter"]

        self.loader = PluginsLoader(Application)
        self.loader.load(dirlist)

        factory = HtmlImproverFactory(Application)
        self.improver = factory["pimprover"]
コード例 #30
0
ファイル: test_thumblist.py プロジェクト: Jenyay/outwiker
    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)
コード例 #31
0
ファイル: test_webpage.py プロジェクト: Jenyay/outwiker
    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)
コード例 #32
0
ファイル: test_langlist.py プロジェクト: Jenyay/outwiker
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'))
コード例 #33
0
ファイル: baseloading.py プロジェクト: LihMeh/outwiker
    def setUp(self):
        BaseMainWndTest.setUp (self)
        self.__createWiki ()

        dirlist = [self.getPluginDir()]

        self.loader = PluginsLoader(Application)
        self.loader.load (dirlist)
コード例 #34
0
ファイル: loader.py プロジェクト: LihMeh/outwiker
    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)
コード例 #35
0
ファイル: test_changetitle.py プロジェクト: rip2503/outwiker
    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()
コード例 #36
0
    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"]
コード例 #37
0
ファイル: test_export2html.py プロジェクト: sarutobi/outwiker
    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
コード例 #38
0
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'))
コード例 #39
0
ファイル: test_varpanel.py プロジェクト: Jenyay/outwiker
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")
コード例 #40
0
ファイル: test_organizer.py プロジェクト: Jenyay/outwiker
    def setUp(self):
        self.initApplication('ru_RU')

        self.__createWiki()

        dirlist = ["../plugins/organizer"]

        self.loader = PluginsLoader(Application)
        self.loader.load(dirlist)
コード例 #41
0
    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()
コード例 #42
0
ファイル: basetestcases.py プロジェクト: unreal666/outwiker
    def setUp(self):
        self.initApplication()
        self.wikiroot = self.createWiki()
        self.__createWiki()

        dirlist = [self.getPluginDir()]

        self.loader = PluginsLoader(self.application)
        self.loader.load(dirlist)
コード例 #43
0
ファイル: test_counterdialog.py プロジェクト: Jenyay/outwiker
    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"]
コード例 #44
0
ファイル: sourcegui.py プロジェクト: DavidWHouse/outwiker
    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)
コード例 #45
0
    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)
コード例 #46
0
ファイル: test_wikicommand.py プロジェクト: sarutobi/outwiker
    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)
コード例 #47
0
    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)
コード例 #48
0
    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)
コード例 #49
0
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
コード例 #50
0
ファイル: test_sourcefile.py プロジェクト: sarutobi/outwiker
    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)
コード例 #51
0
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)
コード例 #52
0
ファイル: test_sourcegui.py プロジェクト: refaqtor/outwiker
    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)
コード例 #53
0
    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)
コード例 #54
0
ファイル: test_sourcefile.py プロジェクト: rip2503/outwiker
    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)
コード例 #55
0
    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')
コード例 #56
0
    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)
コード例 #57
0
ファイル: test_pluginsloader.py プロジェクト: Jenyay/outwiker
    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")
コード例 #58
0
    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)
コード例 #59
0
    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)
コード例 #60
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)