def testSelectedAttach_html (self): Attachment (self._testpage).attach (self.files) parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'{}/add.png'.format (PAGE_ATTACH_DIR) controller = HtmlLinkDialogController (self._testpage, parent, selectedString) controller.showDialog() self.assertIn (u'{}/accept.png'.format (PAGE_ATTACH_DIR), parent.linkText.GetItems()) self.assertIn (u'{}/add.png'.format (PAGE_ATTACH_DIR), parent.linkText.GetItems()) self.assertIn (u'{}/html.txt'.format (PAGE_ATTACH_DIR), parent.linkText.GetItems()) self.assertEqual (controller.link, u'{}/add.png'.format (PAGE_ATTACH_DIR)) self.assertEqual (controller.comment, u'{}/add.png'.format (PAGE_ATTACH_DIR)) self.assertEqual (controller.linkResult, u'<a href="{attach}/add.png">{attach}/add.png</a>'.format (attach=PAGE_ATTACH_DIR)) self.assertEqual (parent.linkText.GetValue(), u'{}/add.png'.format (PAGE_ATTACH_DIR))
def insertLink(application): codeEditor = application.mainWindow.pagePanel.pageView.codeEditor with LinkDialog(application.mainWindow) as dlg: linkController = WikiLinkDialogController(application, application.selectedPage, dlg, codeEditor.GetSelectedText()) if linkController.showDialog() == wx.ID_OK: codeEditor.replaceText(linkController.linkResult)
def testSelectedText_html (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'бла-бла-бла' controller = HtmlLinkDialogController (self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, u'') self.assertEqual (controller.comment, selectedString) self.assertEqual (controller.linkResult, u'<a href="">бла-бла-бла</a>')
def testSelectedHttpLink2_html (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'HTTP://jenyay.net' controller = HtmlLinkDialogController (self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, selectedString) self.assertEqual (controller.comment, selectedString) self.assertEqual (controller.linkResult, u'<a href="HTTP://jenyay.net">HTTP://jenyay.net</a>')
def testSelectedPageLink_html (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'page://__adsfadfasdf' controller = HtmlLinkDialogController (self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, selectedString) self.assertEqual (controller.comment, selectedString) self.assertEqual (controller.linkResult, u'<a href="page://__adsfadfasdf">page://__adsfadfasdf</a>')
def testSelectedHttpLink_wiki (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'http://jenyay.net' controller = WikiLinkDialogController (Application, self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, selectedString) self.assertEqual (controller.comment, selectedString) self.assertEqual (controller.linkResult, u'[[http://jenyay.net]]')
def testEmpty_wiki (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'' controller = WikiLinkDialogController (Application, self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, u'') self.assertEqual (controller.comment, u'') self.assertEqual (controller.linkResult, u'[[]]')
def testSelectedPageLink_wiki (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'page://__adsfadfasdf' controller = WikiLinkDialogController (Application, self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, selectedString) self.assertEqual (controller.comment, selectedString) self.assertEqual (controller.linkResult, u'[[page://__adsfadfasdf]]')
def testAttach_wiki (self): Attachment (self._testpage).attach (self.files) parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'' controller = WikiLinkDialogController (Application, self._testpage, parent, selectedString) controller.showDialog() self.assertIn (u'Attach:accept.png', parent.linkText.GetItems()) self.assertIn (u'Attach:add.png', parent.linkText.GetItems()) self.assertIn (u'Attach:html.txt', parent.linkText.GetItems())
def testClipboardPageLink_wiki (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'' clipboardText = u'page://_asdfasdfasdf' copyTextToClipboard (clipboardText) controller = WikiLinkDialogController (Application, self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, clipboardText) self.assertEqual (controller.comment, clipboardText) self.assertEqual (controller.linkResult, u'[[page://_asdfasdfasdf]]')
def testClipboardHttpLink2_wiki (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'' clipboardText = u'HTTP://jenyay.net' copyTextToClipboard (clipboardText) controller = WikiLinkDialogController (Application, self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, clipboardText) self.assertEqual (controller.comment, clipboardText) self.assertEqual (controller.linkResult, u'[[HTTP://jenyay.net]]')
def testAttach_html (self): Attachment (self._testpage).attach (self.files) parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'' controller = HtmlLinkDialogController (self._testpage, parent, selectedString) controller.showDialog() self.assertIn (u'{}/accept.png'.format (PAGE_ATTACH_DIR), parent.linkText.GetItems()) self.assertIn (u'{}/add.png'.format (PAGE_ATTACH_DIR), parent.linkText.GetItems()) self.assertIn (u'{}/html.txt'.format (PAGE_ATTACH_DIR), parent.linkText.GetItems())
def testClipboardPageLink_html (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'' clipboardText = u'page://_asdfasdfasdf' copyTextToClipboard (clipboardText) controller = HtmlLinkDialogController (self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, clipboardText) self.assertEqual (controller.comment, clipboardText) self.assertEqual ( controller.linkResult, u'<a href="page://_asdfasdfasdf">page://_asdfasdfasdf</a>')
def testClipboardFtpLink_html (self): parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'' clipboardText = u'ftp://jenyay.net' copyTextToClipboard (clipboardText) controller = HtmlLinkDialogController (self._testpage, parent, selectedString) controller.showDialog() self.assertEqual (controller.link, clipboardText) self.assertEqual (controller.comment, clipboardText) self.assertEqual ( controller.linkResult, u'<a href="ftp://jenyay.net">ftp://jenyay.net</a>')
def testLinkStyle_02 (self): self._config.linkStyleOptions.value = 1 dlg = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'' controller = WikiLinkDialogController (Application, self._testpage, dlg, selectedString) dlg.link = u'Ссылка' dlg.comment = u'Коммент' controller.showDialog() self.assertEqual (controller.linkResult, u'[[Ссылка | Коммент]]')
def testSelectedAttach_wiki (self): Attachment (self._testpage).attach (self.files) parent = LinkDialog (self.wnd) Tester.dialogTester.appendOk() selectedString = u'Attach:add.png' controller = WikiLinkDialogController (Application, self._testpage, parent, selectedString) controller.showDialog() self.assertIn (u'Attach:accept.png', parent.linkText.GetItems()) self.assertIn (u'Attach:add.png', parent.linkText.GetItems()) self.assertIn (u'Attach:html.txt', parent.linkText.GetItems()) self.assertEqual (controller.link, u'Attach:add.png') self.assertEqual (controller.comment, u'Attach:add.png') self.assertEqual (controller.linkResult, u'[[Attach:add.png]]') self.assertEqual (parent.linkText.GetValue(), u'Attach:add.png')