Exemplo n.º 1
0
 def _openGlobalSearch(self):
     if self._application.wikiroot is not None:
         try:
             GlobalSearch.create(self._application.wikiroot)
         except IOError:
             MessageBox(_(u"Can't create page"), _(u"Error"),
                        wx.ICON_ERROR | wx.OK)
Exemplo n.º 2
0
 def _openGlobalSearch(self):
     if self._application.wikiroot is not None:
         try:
             GlobalSearch.create(self._application.wikiroot)
         except IOError:
             showError(self._application.mainWindow,
                       _(u"Can't create page"))
Exemplo n.º 3
0
 def _openGlobalSearch (self):
     if self._application.wikiroot != None:
         try:
             GlobalSearch.create (self._application.wikiroot)
         except IOError:
             MessageBox (_(u"Can't create page"), 
                     _(u"Error"), 
                     wx.ICON_ERROR | wx.OK)
Exemplo n.º 4
0
    def testCreateSearchPhrasePage (self):
        GlobalSearch.create (self.rootwiki, phrase = u"декабрь")
        page = self.rootwiki[GlobalSearch.pageTitle]

        self.assertTrue (page != None)
        self.assertEqual (self.rootwiki.selectedPage, page)
        self.assertEqual (page.phrase, u"декабрь")
        self.assertEqual (len (page.searchTags), 0)
        self.assertEqual (page.strategy, AllTagsSearchStrategy)
Exemplo n.º 5
0
    def testCreateDefaultPage (self):
        GlobalSearch.create (self.wikiroot)
        page = self.wikiroot[GlobalSearch.pageTitle]

        self.assertNotEqual (page, None)
        self.assertEqual (self.wikiroot.selectedPage, page)
        self.assertEqual (page.phrase, u"")
        self.assertEqual (len (page.searchTags), 0)
        self.assertEqual (page.strategy, AllTagsSearchStrategy)
Exemplo n.º 6
0
    def testCreateDefaultPage(self):
        GlobalSearch.create(self.wikiroot)
        page = self.wikiroot[GlobalSearch.pageTitle]

        self.assertNotEqual(page, None)
        self.assertEqual(self.wikiroot.selectedPage, page)
        self.assertEqual(page.phrase, "")
        self.assertEqual(len(page.searchTags), 0)
        self.assertEqual(page.strategy, AllTagsSearchStrategy)
Exemplo n.º 7
0
    def testCreateSearchPhrasePage(self):
        GlobalSearch.create(self.wikiroot, phrase=u"декабрь")
        page = self.wikiroot[GlobalSearch.pageTitle]

        self.assertNotEqual(page, None)
        self.assertEqual(self.wikiroot.selectedPage, page)
        self.assertEqual(page.phrase, u"декабрь")
        self.assertEqual(len(page.searchTags), 0)
        self.assertEqual(page.strategy, AllTagsSearchStrategy)
Exemplo n.º 8
0
    def testCreateSearchTagsPage(self):
        GlobalSearch.create(self.wikiroot, tags=[u"Метка 1", u"Метка 2"])
        page = self.wikiroot[GlobalSearch.pageTitle]

        self.assertNotEqual(page, None)
        self.assertEqual(self.wikiroot.selectedPage, page)
        self.assertEqual(page.phrase, u"")
        self.assertEqual(len(page.searchTags), 2)
        self.assertTrue(u"Метка 1" in page.searchTags)
        self.assertTrue(u"Метка 2" in page.searchTags)
        self.assertEqual(page.strategy, AllTagsSearchStrategy)
Exemplo n.º 9
0
    def testCreateSearchTagsPage (self):
        GlobalSearch.create (self.rootwiki, tags = [u"Метка 1", u"Метка 2"])
        page = self.rootwiki[GlobalSearch.pageTitle]

        self.assertTrue (page != None)
        self.assertEqual (self.rootwiki.selectedPage, page)
        self.assertEqual (page.phrase, u"")
        self.assertEqual (len (page.searchTags), 2)
        self.assertTrue (u"Метка 1" in page.searchTags )
        self.assertTrue (u"Метка 2" in page.searchTags)
        self.assertEqual (page.strategy, AllTagsSearchStrategy)
Exemplo n.º 10
0
    def testLoadSearchPage (self):
        GlobalSearch.create (self.rootwiki, 
                phrase = u"декабрь", 
                tags = [u"Метка 1", u"Метка 2"],
                strategy = AllTagsSearchStrategy)

        wiki = WikiDocument.load (self.path)
        page = wiki[GlobalSearch.pageTitle]

        self.assertTrue (page != None)
        self.assertEqual (page.phrase, u"декабрь")
        self.assertEqual (len (page.searchTags), 2)
        self.assertTrue (u"Метка 1" in page.searchTags)
        self.assertTrue (u"Метка 2" in page.searchTags)
        self.assertEqual (page.strategy, AllTagsSearchStrategy)
Exemplo n.º 11
0
    def testCreateSearchAllPage(self):
        GlobalSearch.create(self.wikiroot,
                            phrase="декабрь",
                            tags=["Метка 1", "Метка 2"],
                            strategy=AllTagsSearchStrategy)

        page = self.wikiroot[GlobalSearch.pageTitle]

        self.assertNotEqual(page, None)
        self.assertEqual(self.wikiroot.selectedPage, page)
        self.assertEqual(page.phrase, "декабрь")
        self.assertEqual(len(page.searchTags), 2)
        self.assertTrue("Метка 1" in page.searchTags)
        self.assertTrue("Метка 2" in page.searchTags)
        self.assertEqual(page.strategy, AllTagsSearchStrategy)
Exemplo n.º 12
0
    def testLoadSearchPage(self):
        GlobalSearch.create(self.wikiroot,
                            phrase=u"декабрь",
                            tags=[u"Метка 1", u"Метка 2"],
                            strategy=AllTagsSearchStrategy)

        wiki = WikiDocument.load(self.path)
        page = wiki[GlobalSearch.pageTitle]

        self.assertNotEqual(page, None)
        self.assertEqual(page.phrase, u"декабрь")
        self.assertEqual(len(page.searchTags), 2)
        self.assertTrue(u"Метка 1" in page.searchTags)
        self.assertTrue(u"Метка 2" in page.searchTags)
        self.assertEqual(page.strategy, AllTagsSearchStrategy)
Exemplo n.º 13
0
    def testCreateSearchAllPage (self):
        GlobalSearch.create (self.wikiroot,
                             phrase = u"декабрь",
                             tags = [u"Метка 1", u"Метка 2"],
                             strategy = AllTagsSearchStrategy)

        page = self.wikiroot[GlobalSearch.pageTitle]

        self.assertNotEqual (page, None)
        self.assertEqual (self.wikiroot.selectedPage, page)
        self.assertEqual (page.phrase, u"декабрь")
        self.assertEqual (len (page.searchTags), 2)
        self.assertTrue (u"Метка 1" in page.searchTags)
        self.assertTrue (u"Метка 2" in page.searchTags)
        self.assertEqual (page.strategy, AllTagsSearchStrategy)
Exemplo n.º 14
0
    def testManySearchPages2 (self):
        TextPageFactory().create (self.wikiroot, GlobalSearch.pageTitle, [])

        GlobalSearch.create (self.wikiroot,
                             phrase = u"декабрь",
                             tags = [u"Метка 1", u"Метка 2"],
                             strategy = AllTagsSearchStrategy)

        wiki = WikiDocument.load (self.path)
        page = wiki[GlobalSearch.pageTitle + u" 2"]

        self.assertNotEqual (page, None)
        self.assertEqual (page.phrase, u"декабрь")
        self.assertEqual (len (page.searchTags), 2)
        self.assertTrue (u"Метка 1" in page.searchTags)
        self.assertTrue (u"Метка 2" in page.searchTags)
        self.assertEqual (page.strategy, AllTagsSearchStrategy)
Exemplo n.º 15
0
    def testManySearchPages2(self):
        TextPageFactory().create(self.wikiroot, '# Search', [])

        GlobalSearch.create(self.wikiroot,
                            phrase="декабрь",
                            tags=["Метка 1", "Метка 2"],
                            strategy=AllTagsSearchStrategy)

        wiki = WikiDocument.load(self.path)
        page = wiki['# Search' + " 2"]

        self.assertNotEqual(page, None)
        self.assertEqual(page.phrase, "декабрь")
        self.assertEqual(len(page.searchTags), 2)
        self.assertTrue("Метка 1" in page.searchTags)
        self.assertTrue("Метка 2" in page.searchTags)
        self.assertEqual(page.strategy, AllTagsSearchStrategy)
Exemplo n.º 16
0
    def testManySearchPages1(self):
        GlobalSearch.create(self.wikiroot)

        new_page = GlobalSearch.create(self.wikiroot,
                                       phrase="декабрь",
                                       tags=["Метка 1", "Метка 2"],
                                       strategy=AllTagsSearchStrategy)
        search_title = new_page.title

        wiki = WikiDocument.load(self.path)
        page = wiki[search_title]

        self.assertEqual(wiki[search_title + " 2"], None)
        self.assertNotEqual(page, None)
        self.assertEqual(page.phrase, "декабрь")
        self.assertEqual(len(page.searchTags), 2)
        self.assertTrue("Метка 1" in page.searchTags)
        self.assertTrue("Метка 2" in page.searchTags)
        self.assertEqual(page.strategy, AllTagsSearchStrategy)
Exemplo n.º 17
0
    def testCreateSearchTagsPage(self):
        page = GlobalSearch.create(self.wikiroot, tags=["Метка 1", "Метка 2"])

        self.assertNotEqual(page, None)
        self.assertEqual(self.wikiroot.selectedPage, page)
        self.assertEqual(page.phrase, "")
        self.assertEqual(len(page.searchTags), 2)
        self.assertTrue("Метка 1" in page.searchTags)
        self.assertTrue("Метка 2" in page.searchTags)
        self.assertEqual(page.strategy, AllTagsSearchStrategy)
Exemplo n.º 18
0
    def testManySearchPages3(self):
        factory = TextPageFactory()
        factory.create(self.wikiroot, GlobalSearch.pageTitle, [])
        factory.create(self.wikiroot, GlobalSearch.pageTitle + u" 2", [])
        factory.create(self.wikiroot, GlobalSearch.pageTitle + u" 3", [])
        factory.create(self.wikiroot, GlobalSearch.pageTitle + u" 4", [])

        GlobalSearch.create(self.wikiroot,
                            phrase=u"декабрь",
                            tags=[u"Метка 1", u"Метка 2"],
                            strategy=AllTagsSearchStrategy)

        wiki = WikiDocument.load(self.path)
        page = wiki[GlobalSearch.pageTitle + u" 5"]

        self.assertNotEqual(page, None)
        self.assertEqual(page.phrase, u"декабрь")
        self.assertEqual(len(page.searchTags), 2)
        self.assertTrue(u"Метка 1" in page.searchTags)
        self.assertTrue(u"Метка 2" in page.searchTags)
        self.assertEqual(page.strategy, AllTagsSearchStrategy)
Exemplo n.º 19
0
    def testManySearchPages3 (self):
        TextPageFactory.create (self.rootwiki, GlobalSearch.pageTitle, [])
        TextPageFactory.create (self.rootwiki, GlobalSearch.pageTitle + u" 2", [])
        TextPageFactory.create (self.rootwiki, GlobalSearch.pageTitle + u" 3", [])
        TextPageFactory.create (self.rootwiki, GlobalSearch.pageTitle + u" 4", [])

        GlobalSearch.create (self.rootwiki, 
                phrase = u"декабрь", 
                tags = [u"Метка 1", u"Метка 2"],
                strategy = AllTagsSearchStrategy)

        wiki = WikiDocument.load (self.path)
        page = wiki[GlobalSearch.pageTitle + u" 5"]

        self.assertTrue (page != None)
        #self.assertEqual (wiki.selectedPage, page)
        self.assertEqual (page.phrase, u"декабрь")
        self.assertEqual (len (page.searchTags), 2)
        self.assertTrue (u"Метка 1" in page.searchTags)
        self.assertTrue (u"Метка 2" in page.searchTags)
        self.assertEqual (page.strategy, AllTagsSearchStrategy)
Exemplo n.º 20
0
    def testSetStrategy2(self):
        """
        Тест на то, что сохраняется искомая фраза
        """
        page = GlobalSearch.create(self.wikiroot)

        self.assertEqual(page.phrase, u"")
        self.assertEqual(page.searchTags, [])

        # Поменяем параметры через свойства
        page.strategy = AnyTagSearchStrategy
        self.assertEqual(page.strategy, AnyTagSearchStrategy)

        # Загрузим вики и прочитаем установленные параметры
        wiki = WikiDocument.load(self.path)
        searchPage = wiki[GlobalSearch.pageTitle]

        self.assertNotEqual(searchPage, None)
        self.assertEqual(searchPage.strategy, AnyTagSearchStrategy)
Exemplo n.º 21
0
    def testSetTags (self):
        """
        Тест на то, что сохраняется искомая фраза
        """
        page = GlobalSearch.create (self.wikiroot)

        self.assertEqual (page.phrase, u"")
        self.assertEqual (page.searchTags, [])

        # Поменяем параметры через свойства
        page.searchTags = [u"тег1", u"тег2"]
        self.assertEqual (page.searchTags, [u"тег1", u"тег2"])

        # Загрузим вики и прочитаем установленные параметры
        wiki = WikiDocument.load (self.path)
        searchPage = wiki[GlobalSearch.pageTitle]

        self.assertNotEqual (searchPage, None)
        self.assertEqual (searchPage.searchTags, [u"тег1", u"тег2"])
Exemplo n.º 22
0
    def testSetStrategy2 (self):
        """
        Тест на то, что сохраняется искомая фраза
        """
        page = GlobalSearch.create (self.rootwiki)

        self.assertEqual (page.phrase, u"")
        self.assertEqual (page.searchTags, [])

        # Поменяем параметры через свойства
        page.strategy = AnyTagSearchStrategy
        self.assertEqual (page.strategy, AnyTagSearchStrategy)

        # Загрузим вики и прочитаем установленные параметры
        wiki = WikiDocument.load (self.path)
        searchPage = wiki[GlobalSearch.pageTitle]

        self.assertTrue (searchPage != None)
        self.assertEqual (searchPage.strategy, AnyTagSearchStrategy)
Exemplo n.º 23
0
    def testSetTags(self):
        """
        Тест на то, что сохраняется искомая фраза
        """
        page = GlobalSearch.create(self.wikiroot)
        search_title = page.title

        self.assertEqual(page.phrase, "")
        self.assertEqual(page.searchTags, [])

        # Поменяем параметры через свойства
        page.searchTags = ["тег1", "тег2"]
        self.assertEqual(page.searchTags, ["тег1", "тег2"])

        # Загрузим вики и прочитаем установленные параметры
        wiki = WikiDocument.load(self.path)
        searchPage = wiki[search_title]

        self.assertNotEqual(searchPage, None)
        self.assertEqual(searchPage.searchTags, ["тег1", "тег2"])