Beispiel #1
0
    def testCommand_10(self):
        Tester.dialogTester.appendOk()
        renamePage(self.wikiroot["Страница 1"], "../sadfasdf")

        self.assertIsNotNone(self.wikiroot["Страница 1"])
        self.assertIsNone(self.wikiroot["../sadfasdf"])
        self.assertEqual(Tester.dialogTester.count, 0)
Beispiel #2
0
    def test_some_name(self):
        page = self.wikiroot['Страница 1']
        renamePage(page, 'Страница 1')

        self.assertIsNotNone(self.wikiroot['Страница 1'])
        self.assertEqual(page.display_title, 'Страница 1')
        self.assertIsNone(page.alias)
Beispiel #3
0
    def test_some_name(self):
        page = self.wikiroot['Страница 1']
        renamePage(page, 'Страница 1')

        self.assertIsNotNone(self.wikiroot['Страница 1'])
        self.assertEqual(page.display_title, 'Страница 1')
        self.assertIsNone(page.alias)
Beispiel #4
0
    def testCommand_begins_underlines_02(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "##asdasdf")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot["--asdasdf"])
        self.assertEqual(self.wikiroot["--asdasdf"].alias, '##asdasdf')
Beispiel #5
0
    def testCommand_02(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "Страница 2")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot["Страница 2"])
        self.assertIsNotNone(self.wikiroot["Страница 2 (1)"])
Beispiel #6
0
    def testCommand_02(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "Страница 2")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot["Страница 2"])
        self.assertIsNotNone(self.wikiroot["Страница 2 (1)"])
Beispiel #7
0
    def testCommand_11(self):
        Tester.dialogTester.appendOk()
        renamePage(self.wikiroot["Страница 1"], "..\\Абырвалг")

        self.assertIsNotNone(self.wikiroot["Страница 1"])
        self.assertIsNone(self.wikiroot["..\\Абырвалг"])
        self.assertEqual(Tester.dialogTester.count, 0)
Beispiel #8
0
def editPage(parentWnd, currentPage):
    """
    Вызвать диалог для редактирования страницы
    parentWnd - родительское окно
    currentPage - страница для редактирования
    """
    if currentPage.readonly:
        raise outwiker.core.exceptions.ReadonlyException

    if not pageExists(currentPage):
        MessageBox(
            _(u'Page "%s" not found') % currentPage.display_title, _(u"Error"),
            wx.OK | wx.ICON_ERROR)
        return

    with EditPageDialog(parentWnd, currentPage, Application) as dlg:
        if dlg.ShowModal() == wx.ID_OK:
            # try:
            #     currentPage.display_title = dlg.pageTitle
            # except EnvironmentError as e:
            #     MessageBox(_(u"Can't rename page\n") + str(e),
            #                _(u"Error"),
            #                wx.ICON_ERROR | wx.OK)
            #
            renamePage(currentPage, dlg.pageTitle)
            if not dlg.setPageProperties(currentPage):
                return None
Beispiel #9
0
    def testCommand_13(self):
        Tester.dialogTester.appendOk()
        renamePage(self.wikiroot["Страница 2/Страница 3"], "..")

        self.assertIsNotNone(self.wikiroot["Страница 2/Страница 3"])
        self.assertIsNone(self.wikiroot[".."])
        self.assertEqual(Tester.dialogTester.count, 0)
Beispiel #10
0
    def testCommand_begins_underlines_02(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "##asdasdf")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot["--asdasdf"])
        self.assertEqual(self.wikiroot["--asdasdf"].alias, '##asdasdf')
Beispiel #11
0
    def testCommand_double_dots(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "..")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot["(1)"])
        self.assertEqual(self.wikiroot["(1)"].alias, '..')
Beispiel #12
0
    def testCommand_09 (self):
        Tester.dialogTester.appendOk()
        renamePage (self.wikiroot[u"Страница 1"], u"..\\")

        self.assertIsNotNone (self.wikiroot[u"Страница 1"])
        self.assertIsNone (self.wikiroot[u"..\\"])
        self.assertEqual (Tester.dialogTester.count, 0)
Beispiel #13
0
    def testCommand_double_dots(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "..")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot["(1)"])
        self.assertEqual(self.wikiroot["(1)"].alias, '..')
Beispiel #14
0
    def test_rename_special_chars(self):
        page = self.wikiroot['Страница 1']
        renamePage(page, 'Тест ><|?*:"\\/#% проверка')

        self.assertIsNone(self.wikiroot['Страница 1'])
        self.assertIsNotNone(self.wikiroot['Тест ___________ проверка'])
        self.assertEqual(page.display_title, 'Тест ><|?*:"\\/#% проверка')
        self.assertEqual(page.alias, 'Тест ><|?*:"\\/#% проверка')
Beispiel #15
0
    def test_rename_simple_spaces(self):
        page = self.wikiroot['Страница 1']
        renamePage(page, '   Новое имя   ')

        self.assertIsNone(self.wikiroot['Страница 1'])
        self.assertIsNotNone(self.wikiroot['Новое имя'])
        self.assertEqual(page.display_title, 'Новое имя')
        self.assertIsNone(page.alias)
Beispiel #16
0
    def test_rename_special_chars(self):
        page = self.wikiroot['Страница 1']
        renamePage(page, 'Тест ><|?*:"\\/#% проверка')

        self.assertIsNone(self.wikiroot['Страница 1'])
        self.assertIsNotNone(self.wikiroot['Тест ___________ проверка'])
        self.assertEqual(page.display_title, 'Тест ><|?*:"\\/#% проверка')
        self.assertEqual(page.alias, 'Тест ><|?*:"\\/#% проверка')
Beispiel #17
0
    def test_rename_duplicate_01(self):
        renamePage(self.wikiroot['Страница 2'], 'Страница 1')

        self.assertIsNone(self.wikiroot['Страница 2'])
        self.assertIsNotNone(self.wikiroot['Страница 1 (1)'])
        self.assertEqual(self.wikiroot['Страница 1 (1)'].alias, 'Страница 1')
        self.assertEqual(self.wikiroot['Страница 1 (1)'].display_title,
                         'Страница 1')
Beispiel #18
0
    def test_rename_simple_spaces(self):
        page = self.wikiroot['Страница 1']
        renamePage(page, '   Новое имя   ')

        self.assertIsNone(self.wikiroot['Страница 1'])
        self.assertIsNotNone(self.wikiroot['Новое имя'])
        self.assertEqual(page.display_title, 'Новое имя')
        self.assertIsNone(page.alias)
Beispiel #19
0
    def testCommand_14_root(self):
        self.application.mainWindow.toaster.counter.clear()
        renamePage(self.wikiroot, "Абырвалг")

        self.assertEqual(Tester.dialogTester.count, 0)
        self.assertEqual(self.wikiroot.title, basename(self.wikiroot.path))
        self.assertEqual(
            self.application.mainWindow.toaster.counter.showErrorCount, 1)
Beispiel #20
0
    def test_rename_duplicate_01(self):
        renamePage(self.wikiroot['Страница 2'], 'Страница 1')

        self.assertIsNone(self.wikiroot['Страница 2'])
        self.assertIsNotNone(self.wikiroot['Страница 1 (1)'])
        self.assertEqual(self.wikiroot['Страница 1 (1)'].alias, 'Страница 1')
        self.assertEqual(self.wikiroot['Страница 1 (1)'].display_title,
                         'Страница 1')
Beispiel #21
0
    def test_alias(self):
        self.wikiroot['Страница 1'].alias = 'Бла-бла-бла'
        renamePage(self.wikiroot['Страница 1'], 'Викистраница')

        self.assertIsNotNone(self.wikiroot['Викистраница'])
        self.assertIsNone(self.wikiroot['Викистраница'].alias)
        self.assertEqual(self.wikiroot['Викистраница'].title, 'Викистраница')
        self.assertEqual(self.wikiroot['Викистраница'].display_title,
                         'Викистраница')
Beispiel #22
0
    def testCommand_07_readonly (self):
        self.wikiroot[u"Страница 1"].readonly = True

        Tester.dialogTester.appendOk()
        renamePage (self.wikiroot[u"Страница 1"], u"Абырвалг")

        self.assertIsNotNone (self.wikiroot[u"Страница 1"])
        self.assertIsNone (self.wikiroot[u"Абырвалг"])
        self.assertEqual (Tester.dialogTester.count, 0)
Beispiel #23
0
    def testCommand_14_root(self):
        self.application.mainWindow.toaster.counter.clear()
        renamePage(self.wikiroot, "Абырвалг")

        self.assertEqual(Tester.dialogTester.count, 0)
        self.assertEqual(self.wikiroot.title, basename(self.wikiroot.path))
        self.assertEqual(
            self.application.mainWindow.toaster.counter.showErrorCount,
            1)
Beispiel #24
0
    def test_alias(self):
        self.wikiroot['Страница 1'].alias = 'Бла-бла-бла'
        renamePage(self.wikiroot['Страница 1'], 'Викистраница')

        self.assertIsNotNone(self.wikiroot['Викистраница'])
        self.assertIsNone(self.wikiroot['Викистраница'].alias)
        self.assertEqual(self.wikiroot['Викистраница'].title, 'Викистраница')
        self.assertEqual(self.wikiroot['Викистраница'].display_title,
                         'Викистраница')
Beispiel #25
0
    def testCommand_07_readonly(self):
        self.wikiroot["Страница 1"].readonly = True

        Tester.dialogTester.appendOk()
        renamePage(self.wikiroot["Страница 1"], "Абырвалг")

        self.assertIsNotNone(self.wikiroot["Страница 1"])
        self.assertIsNone(self.wikiroot["Абырвалг"])
        self.assertEqual(Tester.dialogTester.count, 0)
Beispiel #26
0
    def testCommand_07_readonly(self):
        self.application.mainWindow.toaster.counter.clear()
        self.wikiroot["Страница 1"].readonly = True

        renamePage(self.wikiroot["Страница 1"], "Абырвалг")

        self.assertIsNotNone(self.wikiroot["Страница 1"])
        self.assertIsNone(self.wikiroot["Абырвалг"])
        self.assertEqual(
            self.application.mainWindow.toaster.counter.showErrorCount, 1)
Beispiel #27
0
    def testCommand_07_readonly(self):
        self.application.mainWindow.toaster.counter.clear()
        self.wikiroot["Страница 1"].readonly = True

        renamePage(self.wikiroot["Страница 1"], "Абырвалг")

        self.assertIsNotNone(self.wikiroot["Страница 1"])
        self.assertIsNone(self.wikiroot["Абырвалг"])
        self.assertEqual(
            self.application.mainWindow.toaster.counter.showErrorCount,
            1)
Beispiel #28
0
    def __onEndLabelEdit(self, event):
        if event.IsEditCancelled():
            return

        # Новый заголовок
        label = event.GetLabel().strip()

        item = event.GetItem()
        page = self.treeCtrl.GetItemData(item)
        # Не доверяем переименовывать элементы системе
        event.Veto()
        renamePage(page, label)
Beispiel #29
0
    def __onEndLabelEdit(self, event):
        if event.IsEditCancelled():
            return

        # Новый заголовок
        label = event.GetLabel().strip()

        item = event.GetItem()
        page = self.treeCtrl.GetItemData(item)
        # Не доверяем переименовывать элементы системе
        event.Veto()
        renamePage(page, label)
Beispiel #30
0
 def RenamePage(self, manual=False):
     config = PluginConfig(self._application.config)
     if config.autoRenameAllPages or manual:
         currentPage = self._application.selectedPage
         if currentPage is not None and not currentPage.content == "":
             text = currentPage.content.splitlines()[0]
             text = self.getValidName(text)
             if not text == "" and text != currentPage.title:
                 if testPageTitle(text) == True:
                     renamePage(currentPage, text)
     if config.autoSetFirstLine:
         currentPage = self._application.selectedPage
         if currentPage is not None and currentPage.content == "":
             currentPage.content = currentPage.title
Beispiel #31
0
	def RenamePage (self, manual=False):
		config = PluginConfig (self._application.config)
		if config.autoRenameAllPages or manual:
			currentPage = self._application.selectedPage
			if currentPage is not None and not currentPage.content == "":
				text = currentPage.content.splitlines()[0]
				text = self.getValidName(text)
				if not text == "" and text != currentPage.title:
					if testPageTitle (text) == True:
						renamePage(currentPage, text)
		if config.autoSetFirstLine:
			currentPage = self._application.selectedPage
			if currentPage is not None and currentPage.content == "":
				currentPage.content = currentPage.title
Beispiel #32
0
def editPage(parentWnd, currentPage):
    """
    Вызвать диалог для редактирования страницы
    parentWnd - родительское окно
    currentPage - страница для редактирования
    """
    if currentPage.readonly:
        raise outwiker.core.exceptions.ReadonlyException

    if not pageExists(currentPage):
        showError(Application.mainWindow,
                  _(u'Page "%s" not found') % currentPage.display_title)
        return

    with EditPageDialog(parentWnd, currentPage, Application) as dlg:
        if dlg.ShowModal() == wx.ID_OK:
            renamePage(currentPage, dlg.pageTitle)
            if not dlg.setPageProperties(currentPage):
                return None
Beispiel #33
0
def editPage(parentWnd, currentPage):
    """
    Вызвать диалог для редактирования страницы
    parentWnd - родительское окно
    currentPage - страница для редактирования
    """
    if currentPage.readonly:
        raise outwiker.core.exceptions.ReadonlyException

    if not pageExists(currentPage):
        showError(Application.mainWindow,
                  _(u'Page "%s" not found') % currentPage.display_title)
        return

    with EditPageDialog(parentWnd, currentPage, Application) as dlg:
        if dlg.ShowModal() == wx.ID_OK:
            renamePage(currentPage, dlg.pageTitle)
            if not dlg.setPageProperties(currentPage):
                return None
Beispiel #34
0
    def testCommand_14_root (self):
        Tester.dialogTester.appendOk()
        renamePage (self.wikiroot, u"Абырвалг")

        self.assertEqual (Tester.dialogTester.count, 0)
        self.assertEqual (self.wikiroot.title, basename (self.path))
Beispiel #35
0
    def testCommand_01 (self):
        renamePage (self.wikiroot[u"Страница 1"], u"Абырвалг")

        self.assertIsNone (self.wikiroot[u"Страница 1"])
        self.assertIsNotNone (self.wikiroot[u"Абырвалг"])
Beispiel #36
0
    def testCommand_01(self):
        renamePage(self.wikiroot["Страница 1"], "Абырвалг")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot["Абырвалг"])
Beispiel #37
0
    def testCommand_14_root(self):
        Tester.dialogTester.appendOk()
        renamePage(self.wikiroot, "Абырвалг")

        self.assertEqual(Tester.dialogTester.count, 0)
        self.assertEqual(self.wikiroot.title, basename(self.wikiroot.path))
Beispiel #38
0
    def testCommand_12(self):
        renamePage(self.wikiroot["Страница 2/Страница 3"], "Абырвалг")

        self.assertIsNone(self.wikiroot["Страница 2/Страница 3"])
        self.assertIsNotNone(self.wikiroot["Страница 2"])
        self.assertIsNotNone(self.wikiroot["Страница 2/Абырвалг"])
Beispiel #39
0
    def testCommand_10(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "../sadfasdf")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot[".._sadfasdf"])
Beispiel #40
0
    def testCommand_03(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "safsd/Абырвалг")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot["safsd_Абырвалг"])
Beispiel #41
0
    def testCommand_13(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 2/Страница 3"], "..")

        self.assertIsNone(self.wikiroot["Страница 2/Страница 3"])
        self.assertIsNone(self.wikiroot[".."])
Beispiel #42
0
    def testCommand_11(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "..\\Абырвалг")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot[".._Абырвалг"])
Beispiel #43
0
    def testCommand_03(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "safsd/Абырвалг")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot["safsd_Абырвалг"])
Beispiel #44
0
    def testCommand_10(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "../sadfasdf")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot[".._sadfasdf"])
Beispiel #45
0
    def testCommand_11(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 1"], "..\\Абырвалг")

        self.assertIsNone(self.wikiroot["Страница 1"])
        self.assertIsNotNone(self.wikiroot[".._Абырвалг"])
Beispiel #46
0
    def testCommand_13(self):
        Tester.dialogTester.appendError()
        renamePage(self.wikiroot["Страница 2/Страница 3"], "..")

        self.assertIsNone(self.wikiroot["Страница 2/Страница 3"])
        self.assertIsNone(self.wikiroot[".."])
Beispiel #47
0
    def testCommand_12(self):
        renamePage(self.wikiroot["Страница 2/Страница 3"], "Абырвалг")

        self.assertIsNone(self.wikiroot["Страница 2/Страница 3"])
        self.assertIsNotNone(self.wikiroot["Страница 2"])
        self.assertIsNotNone(self.wikiroot["Страница 2/Абырвалг"])