Example #1
0
    def testPageSelectLoad(self):
        Application.onPageSelect += self.pageSelect

        removeDir(self.path)

        rootwiki = WikiDocument.create(self.path)
        TextPageFactory().create(rootwiki, u"Страница 1", [])
        TextPageFactory().create(rootwiki, u"Страница 2", [])
        TextPageFactory().create(rootwiki[u"Страница 2"], u"Страница 3", [])

        document = WikiDocument.load(self.path)
        Application.wikiroot = document

        self.assertEqual(document.selectedPage, None)

        document.selectedPage = document[u"Страница 1"]

        self.assertEqual(document.selectedPage, document[u"Страница 1"])
        self.assertEqual(self.isPageSelect, True)
        self.assertEqual(self.pageSelectSender, document[u"Страница 1"])
        self.assertEqual(self.pageSelectCount, 1)

        document.selectedPage = document[u"Страница 2/Страница 3"]

        self.assertEqual(document.selectedPage, document[u"Страница 2/Страница 3"])
        self.assertEqual(self.isPageSelect, True)
        self.assertEqual(self.pageSelectSender, document[u"Страница 2/Страница 3"])
        self.assertEqual(self.pageSelectCount, 2)

        Application.onPageSelect -= self.pageSelect
Example #2
0
    def testReloading (self):
        attach = Attachment (self.page)
        attach.attach (self.fullFilesPath)

        self.wikiroot.selectedPage = self.page
        Application.wikiroot = self.wikiroot

        self.assertEqual (self.wnd.attachPanel.panel.attachList.GetItemCount(), len (self.fullFilesPath))

        # Создадим другую независимую вики
        newpath = mkdtemp (prefix=u'Абыр Абырвалг')
        newwikiroot = WikiDocument.create (newpath)

        TextPageFactory().create (newwikiroot, u"Новая страница 1", [])
        TextPageFactory().create (newwikiroot, u"Новая страница 2", [])

        filesPath = u"../test/samplefiles/"
        newfiles = [u"accept.png", u"add.png", u"anchor.png"]
        newfullFilesPath = [os.path.join (filesPath, fname) for fname in newfiles]

        newattach = Attachment (newwikiroot[u"Новая страница 1"])
        newattach.attach (newfullFilesPath)
        newwikiroot.selectedPage = newwikiroot[u"Новая страница 1"]

        Application.wikiroot = newwikiroot
        self.assertEqual (self.wnd.attachPanel.panel.attachList.GetItemCount(), len (newfullFilesPath))

        Application.wikiroot.selectedPage = None
        Application.wikiroot = None
        removeDir (newpath)
Example #3
0
    def testUpdateIconNoEvent(self):
        """
        Тест на НЕсрабатывание событий при обновлении иконки, если не устанолен Application.wikiroot
        """
        Application.wikiroot = None

        Application.onPageUpdate += self.pageUpdate
        Application.onTreeUpdate += self.treeUpdate

        removeDir(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertFalse(self.isPageUpdate)
        self.assertFalse(self.isPageCreate)

        # Создаем вики
        rootwiki = WikiDocument.create(self.path)
        TextPageFactory().create(rootwiki, u"Страница 1", [])

        Application.wikiroot = rootwiki

        # Изменим содержимое страницы
        rootwiki[u"Страница 1"].icon = "../test/images/feed.gif"

        self.assertTrue(self.isPageUpdate)
        self.assertEqual(self.pageUpdateSender, rootwiki[u"Страница 1"])

        self.assertFalse(self.isTreeUpdate)

        Application.onPageUpdate -= self.pageUpdate
        Application.onTreeUpdate -= self.treeUpdate
Example #4
0
 def tearDown(self):
     Tester.dialogTester.clear()
     self.application.wikiroot = None
     removeDir(self.wikiroot.path)
     self._loader.clear()
     self.destroyApplication()
     self.destroyWiki(self.wikiroot)
Example #5
0
 def tearDown(self):
     self.application.selectedPage = None
     self.application.wikiroot = None
     self.loader.clear()
     self.destroyApplication()
     if os.path.exists(self.path):
         removeDir(self.path)
Example #6
0
    def testUpdateIcon(self):
        """
        Тест на срабатывание событий при обновлении иконки
        """
        Application.onPageUpdate += self.pageUpdate
        Application.onTreeUpdate += self.treeUpdate

        removeDir(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertFalse(self.isPageUpdate)
        self.assertFalse(self.isPageCreate)

        # Создаем вики
        rootwiki = WikiDocument.create(self.path)
        TextPageFactory().create(rootwiki, u"Страница 1", [])

        Application.wikiroot = rootwiki

        # Изменим содержимое страницы
        rootwiki[u"Страница 1"].icon = "../test/images/feed.gif"

        self.assertTrue(self.isPageUpdate)
        self.assertEqual(self.pageUpdateSender, rootwiki[u"Страница 1"])
        self.assertEqual(self.prev_kwargs["change"], PAGE_UPDATE_ICON)

        self.assertFalse(self.isTreeUpdate)

        Application.onPageUpdate -= self.pageUpdate
        Application.onTreeUpdate -= self.treeUpdate
Example #7
0
    def testUpdateTagsEvent(self):
        """
        Тест на срабатывание событий при обновлении меток (тегов)
        """
        Application.onPageUpdate += self.pageUpdate

        removeDir(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertFalse(self.isPageUpdate)
        self.assertFalse(self.isPageCreate)

        # Создаем вики
        rootwiki = WikiDocument.create(self.path)
        TextPageFactory().create(rootwiki, u"Страница 1", [])

        Application.wikiroot = rootwiki

        # Изменим содержимое страницы
        rootwiki[u"Страница 1"].tags = ["test"]

        self.assertTrue(self.isPageUpdate)
        self.assertEqual(self.pageUpdateSender, rootwiki[u"Страница 1"])
        self.assertEqual(self.prev_kwargs["change"], PAGE_UPDATE_TAGS)

        Application.onPageUpdate -= self.pageUpdate
Example #8
0
    def testUpdateContentEvent(self):
        """
        Тест на срабатывание событий при обновлении контента
        """
        Application.onPageUpdate += self.pageUpdate

        removeDir(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertFalse(self.isPageUpdate)
        self.assertFalse(self.isPageCreate)

        # Создаем вики
        rootwiki = WikiDocument.create(self.path)
        TextPageFactory().create(rootwiki, u"Страница 1", [])

        Application.wikiroot = rootwiki

        # Изменим содержимое страницы
        rootwiki[u"Страница 1"].content = "1111"

        self.assertTrue(self.isPageUpdate)
        self.assertEqual(self.pageUpdateSender, rootwiki[u"Страница 1"])
        self.assertEqual(self.prev_kwargs["change"], PAGE_UPDATE_CONTENT)

        Application.onPageUpdate -= self.pageUpdate
        Application.wikiroot = None
Example #9
0
    def testInvalidWikiRoot2 (self):
        """
        Тест на обработку ошибки в файле __page.opt корня вики
        """
        def __createInvalidWiki2 ():
            # Здесь будет создаваться вики
            path = mkdtemp (prefix=u'Абырвалг абыр')
            removeDir (path)

            rootwiki = WikiDocument.create (path)

            factory = TextPageFactory()
            factory.create (rootwiki, u"Страница 1", [])
            factory.create (rootwiki[u"Страница 1"], u"Страница 2", [])

            # Испортим файл __page.opt
            with open (os.path.join (rootwiki.path, u"__page.opt"), "w") as fp:
                fp.write (u"[General]\naaa=xxx\n<<<<<<<<wsfsdf sdf sdfasdfdsf \nasfasdsadf")

            return path

        path = __createInvalidWiki2 ()
        WikiDocument.load (path)

        removeDir (path)
Example #10
0
 def tearDown (self):
     from sessions.sessionstorage import SessionStorage
     super (SessionsTest, self).tearDown ()
     Application.wikiroot = None
     Application.config.remove_section (SessionStorage.SECTION_NAME)
     self.loader.clear()
     removeDir (self.path2)
Example #11
0
    def tearDown(self):
        Tester.dialogTester.clear()
        Application.wikiroot = None

        removeDir(self.path)
        self._loader.clear()

        BaseMainWndTest.tearDown(self)
Example #12
0
    def tearDown(self):
        Application.wikiroot = None

        removeDir(self.path)
        self._dlg.Destroy()
        self._loader.clear()

        BaseMainWndTest.tearDown(self)
Example #13
0
 def tearDown(self):
     from sessions.sessionstorage import SessionStorage
     self.application.wikiroot = None
     self.application.config.remove_section(SessionStorage.SECTION_NAME)
     self.loader.clear()
     removeDir(self.path2)
     self.destroyApplication()
     self.destroyWiki(self.wikiroot)
Example #14
0
    def __createWiki(self):
        # Здесь будет создаваться вики
        self.path = "../test/testwiki"
        removeDir(self.path)

        self.rootwiki = WikiDocument.create(self.path)

        WikiPageFactory().create(self.rootwiki, "Страница 1", [])
        self.testPage = self.rootwiki["Страница 1"]
Example #15
0
    def testSaveLoad_03(self):
        depot = PageUidDepot()
        uid = depot.createUid(self.wikiroot["Страница 1"])

        depot_new = PageUidDepot(self.wikiroot)

        self.assertEqual(depot_new[uid].title, "Страница 1")

        removeDir(self.path)
Example #16
0
    def tearDown(self):
        Application.wikiroot = None
        os.chmod (self._getConfigPath (self.wikiroot), stat.S_IRUSR | stat.S_IXUSR | stat.S_IWUSR)
        os.chmod (self._getConfigPath (self.wikiroot[u"Страница 1"]), stat.S_IRUSR | stat.S_IXUSR | stat.S_IWUSR)

        if self.wikiroot[u"Страница 2"] is not None:
            os.chmod (self._getConfigPath (self.wikiroot[u"Страница 2"]), stat.S_IRUSR | stat.S_IXUSR | stat.S_IWUSR)

        removeDir (self.path)
Example #17
0
    def tearDown (self):
        wx.GetApp().Yield()
        self.wnd.Close()
        self.wnd.Hide()
        self._processEvents()

        Application.mainWindow = None
        Application.selectedPage = None
        Application.wikiroot = None
        removeDir (self.path)
Example #18
0
    def tearDown (self):
        # obj = Application.actionController

        wx.GetApp().Yield()
        self.wnd.Close()
        self.wnd.Hide()
        self._processEvents()

        Application.mainWindow = None
        Application.selectedPage = None
        Application.wikiroot = None
        Application.actionController.destroy()
        Application.actionController = None
        removeDir (self.path)
        self.wnd = None
Example #19
0
    def testCreateEvent(self):
        Application.onTreeUpdate += self.treeUpdate
        Application.onPageCreate += self.pageCreate

        removeDir(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertFalse(self.isPageUpdate)
        self.assertFalse(self.isPageCreate)

        # Создаем вики
        rootwiki = WikiDocument.create(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertEqual(self.treeUpdateSender, None)

        Application.wikiroot = rootwiki

        # Создаем страницу верхнего уровня(не считая корня)
        self.isPageCreate = False
        self.pageCreateSender = None

        TextPageFactory().create(rootwiki, u"Страница 1", [])

        self.assertTrue(self.isPageCreate)
        self.assertEqual(self.pageCreateSender, rootwiki[u"Страница 1"])

        # Создаем еще одну страницу
        self.isPageCreate = False
        self.pageCreateSender = None

        TextPageFactory().create(rootwiki, u"Страница 2", [])

        self.assertTrue(self.isPageCreate)
        self.assertEqual(self.pageCreateSender, rootwiki[u"Страница 2"])

        # Создаем подстраницу
        self.isPageCreate = False
        self.pageCreateSender = None

        TextPageFactory().create(rootwiki[u"Страница 2"], u"Страница 3", [])

        self.assertTrue(self.isPageCreate)
        self.assertEqual(self.pageCreateSender,
                         rootwiki[u"Страница 2/Страница 3"])

        Application.onTreeUpdate -= self.treeUpdate
        Application.onPageCreate -= self.pageCreate
Example #20
0
        def __createInvalidWiki2():
            # Здесь будет создаваться вики
            path = mkdtemp(prefix='Абырвалг абыр')
            removeDir(path)

            rootwiki = WikiDocument.create(path)

            factory = TextPageFactory()
            factory.create(rootwiki, "Страница 1", [])
            factory.create(rootwiki["Страница 1"], "Страница 2", [])

            # Испортим файл __page.opt
            with open(os.path.join(rootwiki.path, "__page.opt"), "w") as fp:
                fp.write("[General]\naaa=xxx\n<<<<<<<<wsfsdf sdf sdfasdfdsf \nasfasdsadf")

            return path
Example #21
0
    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
Example #22
0
    def testPageSelectCreateNoEvent(self):
        Application.onPageSelect += self.pageSelect

        removeDir(self.path)

        rootwiki = WikiDocument.create(self.path)
        TextPageFactory().create(rootwiki, u"Страница 1", [])
        TextPageFactory().create(rootwiki, u"Страница 2", [])
        TextPageFactory().create(rootwiki[u"Страница 2"], u"Страница 3", [])

        Application.wikiroot = rootwiki

        self.assertEqual(rootwiki.selectedPage, None)

        rootwiki.selectedPage = rootwiki[u"Страница 1"]

        self.assertEqual(rootwiki.selectedPage, rootwiki[u"Страница 1"])
        self.assertEqual(self.isPageSelect, True)
Example #23
0
    def testUpdateContentNoEvent(self):
        """
        Тест на НЕсрабатывание событий при обновлении контента
        """
        Application.onPageUpdate += self.pageUpdate

        removeDir(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertFalse(self.isPageUpdate)
        self.assertFalse(self.isPageCreate)

        # Создаем вики
        rootwiki = WikiDocument.create(self.path)
        TextPageFactory().create(rootwiki, u"Страница 1", [])

        # Изменим содержимое страницы
        rootwiki[u"Страница 1"].content = "1111"

        self.assertFalse(self.isPageUpdate)
        self.assertEqual(self.pageUpdateSender, None)

        Application.onPageUpdate -= self.pageUpdate
Example #24
0
    def testUpdateTagsNoEvent(self):
        """
        Тест на срабатывание событий при обновлении меток (тегов)
        """
        Application.onPageUpdate += self.pageUpdate

        removeDir(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertFalse(self.isPageUpdate)
        self.assertFalse(self.isPageCreate)

        # Создаем вики
        rootwiki = WikiDocument.create(self.path)
        TextPageFactory().create(rootwiki, u"Страница 1", [])

        # Изменим содержимое страницы
        rootwiki[u"Страница 1"].tags = ["test"]

        self.assertFalse(self.isPageUpdate)
        self.assertEqual(self.pageUpdateSender, None)

        Application.onPageUpdate -= self.pageUpdate
Example #25
0
    def testCreateNoEvent(self):
        Application.onTreeUpdate += self.treeUpdate
        Application.onPageCreate += self.pageCreate

        removeDir(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertFalse(self.isPageUpdate)
        self.assertFalse(self.isPageCreate)

        # Создаем вики
        rootwiki = WikiDocument.create(self.path)

        self.assertFalse(self.isTreeUpdate)
        self.assertEqual(self.treeUpdateSender, None)

        # Создаем страницу верхнего уровня (не считая корня)
        self.isPageCreate = False
        self.pageCreateSender = None

        TextPageFactory().create(rootwiki, u"Страница 1", [])

        self.assertFalse(self.isPageCreate)
        self.assertEqual(self.pageCreateSender, None)
Example #26
0
 def tearDown(self):
     removeDir (self.path)
Example #27
0
 def tearDown(self):
     self.destroyApplication()
     removeDir(self.path)
Example #28
0
 def tearDown(self):
     Application.wikiroot = None
     removeDir(self.path)
Example #29
0
 def tearDown(self):
     self.config.tabWidth.value = 4
     Application.config.remove_section (self.config.section)
     removeDir (self.path)
     self.loader.clear()
Example #30
0
 def tearDown (self):
     removeDir (self.path)
     self.loader.clear()