Exemple #1
0
    def testLinkToPageByProticolLongNames(self):
        """
        Тест на проверку того, что заменяются ссылки вида page://...
        """
        from export2html.longnamegenerator import LongNameGenerator
        from export2html.branchexporter import BranchExporter

        Application.wikiroot = self.root
        namegenerator = LongNameGenerator(self.root)
        branchExporter = BranchExporter(self.root, namegenerator, Application)

        branchExporter.export(
            outdir=self.outputdir,
            imagesonly=False,
            alwaysOverwrite=False
        )

        text = readTextFile(
            os.path.join(
                self.outputdir,
                "samplewiki_Страница 1.html"))

        self.assertIn(
            '<a href="samplewiki_Страница 1_Страница 2_Страница 6_Страница 7_Страница 2.html">',
            text)
Exemple #2
0
    def testBranchContentTitleNames2(self):
        """
        Экспорт дерева с короткими именами
        """
        from export2html.titlenamegenerator import TitleNameGenerator
        from export2html.branchexporter import BranchExporter

        pagename = "Страница 1"
        namegenerator = TitleNameGenerator(self.outputdir)
        branchExporter = BranchExporter(
            self.root[pagename], namegenerator, Application)

        branchExporter.export(
            outdir=self.outputdir,
            imagesonly=False,
            alwaysOverwrite=False
        )

        text = readTextFile(
            os.path.join(
                self.outputdir,
                "Страница 2 (2).html"))

        self.assertTrue('<img src="Страница 2 (2)/cd.png"/>' in text)
        self.assertTrue(
            '<a href="Страница 2 (2)/cd_go.png">cd_go.png</a>' in text)
Exemple #3
0
    def testBranchContentTitleNames2(self):
        """
        Экспорт дерева с короткими именами
        """
        from export2html.titlenamegenerator import TitleNameGenerator
        from export2html.branchexporter import BranchExporter

        pagename = "Страница 1"
        namegenerator = TitleNameGenerator(self.outputdir)
        branchExporter = BranchExporter(
            self.root[pagename], namegenerator, Application)

        branchExporter.export(
            outdir=self.outputdir,
            imagesonly=False,
            alwaysOverwrite=False
        )

        text = readTextFile(
            os.path.join(
                self.outputdir,
                "Страница 2 (2).html"))

        self.assertTrue('<img src="Страница 2 (2)/cd.png"/>' in text)
        self.assertTrue(
            '<a href="Страница 2 (2)/cd_go.png">cd_go.png</a>' in text)
Exemple #4
0
    def testLinkToPageByProticolLongNames(self):
        """
        Тест на проверку того, что заменяются ссылки вида page://...
        """
        from export2html.longnamegenerator import LongNameGenerator
        from export2html.branchexporter import BranchExporter

        Application.wikiroot = self.root
        namegenerator = LongNameGenerator(self.root)
        branchExporter = BranchExporter(self.root, namegenerator, Application)

        branchExporter.export(
            outdir=self.outputdir,
            imagesonly=False,
            alwaysOverwrite=False
        )

        text = readTextFile(
            os.path.join(
                self.outputdir,
                "samplewiki_Страница 1.html"))

        self.assertIn(
            '<a href="samplewiki_Страница 1_Страница 2_Страница 6_Страница 7_Страница 2.html">',
            text)
    def testLinkToPagesHtmlTitleNames(self):
        """
        Тест для проверки того, как исправляются ссылки на страницы
        """
        from export2html.titlenamegenerator import TitleNameGenerator
        from export2html.branchexporter import BranchExporter

        pagename = u"Страница 1"
        namegenerator = TitleNameGenerator(self.outputdir)
        branchExporter = BranchExporter(self.root[pagename], namegenerator, Application)

        branchExporter.export(outdir=self.outputdir, imagesonly=False, alwaysOverwrite=False)

        text = readTextFile(os.path.join(self.outputdir, u"Страница 6.html"))

        self.assertTrue(u'<A HREF="/Типы страниц">/Типы страниц</A>' in text)

        self.assertTrue(
            u'<A HREF="Страница 2 (2).html">/Страница 1/Страница 2/Страница 6/Страница 7/Страница 2</A>' in text
        )

        self.assertTrue(u'<A HREF="Страница 2 (2).html">Страница 7/Страница 2</A>' in text)

        self.assertTrue(u'<A HREF="Страница 2 (2).html">Еще одна ссылка</A>' in text)

        self.assertTrue(u'<A HREF="Страница 7.html">Страница 7</A>' in text)

        self.assertTrue(
            u'<A HREF="Страница 2 (2).html" title="бла-бла-бла">Ссылка на /Страница 1/Страница 2/Страница 6/Страница 7/Страница 2</A>'
            in text
        )

        self.assertTrue(u'<A HREF="Страница 7.html" title="бла-бла-бла">Ссылка на Страницу 7</A>' in text)
    def testExportBranchFiles(self):
        """
        Экспорт дерева
        """
        from export2html.longnamegenerator import LongNameGenerator
        from export2html.branchexporter import BranchExporter

        pagename = u"Страница 1"
        namegenerator = LongNameGenerator(self.root[pagename])
        branchExporter = BranchExporter(self.root[pagename], namegenerator, Application)

        result = branchExporter.export(outdir=self.outputdir, imagesonly=False, alwaysOverwrite=False)

        self.assertEqual(len(result), 0)

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename)))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + ".html")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename, "__icon.png")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2.html")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2", "__icon.gif")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2_Страница 5")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2_Страница 5.html")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2_Страница 5", "__icon.gif"))
        )

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2_Страница 6")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2_Страница 6.html")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2_Страница 6", "__icon.png"))
        )

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2_Страница 6_Страница 7")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2_Страница 6_Страница 7.html"))
        )
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, pagename + u"_Страница 2_Страница 6_Страница 7", "__icon.png"))
        )

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, "__index.html")))
        self.assertTrue(os.path.isfile(os.path.join(self.outputdir, "__index.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, PAGE_RESULT_HTML)))
        self.assertTrue(os.path.isfile(os.path.join(self.outputdir, PAGE_RESULT_HTML)))
    def testRelativeLinkTitleNames_02(self):
        """
        Тест на проверку того, что заменяются ссылки вида page://...
        """
        from export2html.titlenamegenerator import TitleNameGenerator
        from export2html.branchexporter import BranchExporter

        Application.wikiroot = self.root
        namegenerator = TitleNameGenerator(self.outputdir)
        branchExporter = BranchExporter(self.root, namegenerator, Application)

        branchExporter.export(outdir=self.outputdir, imagesonly=False, alwaysOverwrite=False)

        text = readTextFile(os.path.join(self.outputdir, u"Страница 2 (2).html"))

        self.assertIn(u'<a href="Страница 7.html">', text)
    def testLinkToPagesHtmlLongNames(self):
        """
        Тест для проверки того, как исправляются ссылки на страницы
        """
        from export2html.longnamegenerator import LongNameGenerator
        from export2html.branchexporter import BranchExporter

        pagename = u"Страница 1"
        namegenerator = LongNameGenerator(self.root[pagename])
        branchExporter = BranchExporter(self.root[pagename], namegenerator,
                                        Application)

        branchExporter.export(outdir=self.outputdir,
                              imagesonly=False,
                              alwaysOverwrite=False)

        text = readTextFile(
            os.path.join(self.outputdir,
                         u"Страница 1_Страница 2_Страница 6.html"))

        self.assertTrue(u'<A HREF="/Типы страниц">/Типы страниц</A>' in text)

        self.assertTrue(
            u'<A HREF="Страница 1_Страница 2_Страница 6_Страница 7_Страница 2.html">/Страница 1/Страница 2/Страница 6/Страница 7/Страница 2</A>'
            in text)

        self.assertTrue(
            u'<A HREF="Страница 1_Страница 2_Страница 6_Страница 7_Страница 2.html">Страница 7/Страница 2</A>'
            in text)

        self.assertTrue(
            u'<A HREF="Страница 1_Страница 2_Страница 6_Страница 7_Страница 2.html">Еще одна ссылка</A>'
            in text)

        self.assertTrue(
            u'<A HREF="Страница 1_Страница 2_Страница 6_Страница 7.html">Страница 7</A>'
            in text)

        self.assertTrue(
            u'<A HREF="Страница 1_Страница 2_Страница 6_Страница 7_Страница 2.html" title="бла-бла-бла">Ссылка на /Страница 1/Страница 2/Страница 6/Страница 7/Страница 2</A>'
            in text)

        self.assertTrue(
            u'<A HREF="Страница 1_Страница 2_Страница 6_Страница 7.html" title="бла-бла-бла">Ссылка на Страницу 7</A>'
            in text)
    def testLinkToPageByProticolTitleNames_01(self):
        """
        Тест на проверку того, что заменяются ссылки вида page://...
        """
        from export2html.titlenamegenerator import TitleNameGenerator
        from export2html.branchexporter import BranchExporter

        Application.wikiroot = self.root
        namegenerator = TitleNameGenerator(self.outputdir)
        branchExporter = BranchExporter(self.root, namegenerator, Application)

        branchExporter.export(outdir=self.outputdir,
                              imagesonly=False,
                              alwaysOverwrite=False)

        text = readTextFile(os.path.join(self.outputdir, u"Страница 1.html"))

        self.assertIn(u'<a href="Страница 2 (2).html">', text)
Exemple #10
0
    def testExportBranchRoot(self):
        """
        Экспорт, начиная с корня дерева
        """
        from export2html.longnamegenerator import LongNameGenerator
        from export2html.branchexporter import BranchExporter

        wikiname = "samplewiki"
        namegenerator = LongNameGenerator(self.root)
        branchExporter = BranchExporter(self.root, namegenerator, Application)

        result = branchExporter.export(
            outdir=self.outputdir,
            imagesonly=False,
            alwaysOverwrite=False
        )

        self.assertEqual(len(result), 1)
        self.assertTrue("Страница поиска" in result[0])

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 5")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 5.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 6")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 6.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 6_Страница 7")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 6_Страница 7.html")))
Exemple #11
0
    def testExportBranchRoot(self):
        """
        Экспорт, начиная с корня дерева
        """
        from export2html.longnamegenerator import LongNameGenerator
        from export2html.branchexporter import BranchExporter

        wikiname = "samplewiki"
        namegenerator = LongNameGenerator(self.root)
        branchExporter = BranchExporter(self.root, namegenerator, Application)

        result = branchExporter.export(
            outdir=self.outputdir,
            imagesonly=False,
            alwaysOverwrite=False
        )

        self.assertEqual(len(result), 3)

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 5")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 5.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 6")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 6.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 6_Страница 7")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir,
                                                    wikiname + "_Страница 1_Страница 2_Страница 6_Страница 7.html")))
    def testExportBranchFilesTitleNames(self):
        """
        Экспорт дерева с короткими именами
        """
        from export2html.titlenamegenerator import TitleNameGenerator
        from export2html.branchexporter import BranchExporter

        pagename = u"Страница 1"
        namegenerator = TitleNameGenerator(self.outputdir)
        branchExporter = BranchExporter(self.root[pagename], namegenerator, Application)

        result = branchExporter.export(outdir=self.outputdir, imagesonly=False, alwaysOverwrite=False)

        self.assertEqual(len(result), 0, str(result))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename)))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename + ".html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 2")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 2.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 2 (1)")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 2 (1).html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 2 (2)")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 2 (2).html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 5")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 5.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 6")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 6.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 7")))
        self.assertTrue(os.path.exists(os.path.join(self.outputdir, u"Страница 7.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, "__index.html")))
        self.assertTrue(os.path.isfile(os.path.join(self.outputdir, "__index.html")))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, PAGE_RESULT_HTML)))
        self.assertTrue(os.path.isfile(os.path.join(self.outputdir, PAGE_RESULT_HTML)))
Exemple #13
0
    def testExportBranchFilesTitleNames(self):
        """
        Экспорт дерева с короткими именами
        """
        from export2html.titlenamegenerator import TitleNameGenerator
        from export2html.branchexporter import BranchExporter

        pagename = u"Страница 1"
        namegenerator = TitleNameGenerator(self.outputdir)
        branchExporter = BranchExporter(self.root[pagename], namegenerator,
                                        Application)

        result = branchExporter.export(outdir=self.outputdir,
                                       imagesonly=False,
                                       alwaysOverwrite=False)

        self.assertEqual(len(result), 0, str(result))

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename)))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, pagename + ".html")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 2")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 2.html")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 2 (1)")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir,
                                        u"Страница 2 (1).html")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 2 (2)")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir,
                                        u"Страница 2 (2).html")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 5")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 5.html")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 6")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 6.html")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 7")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, u"Страница 7.html")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, "__index.html")))
        self.assertTrue(
            os.path.isfile(os.path.join(self.outputdir, "__index.html")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, PAGE_RESULT_HTML)))
        self.assertTrue(
            os.path.isfile(os.path.join(self.outputdir, PAGE_RESULT_HTML)))
Exemple #14
0
    def testExportBranchFiles(self):
        """
        Экспорт дерева
        """
        from export2html.longnamegenerator import LongNameGenerator
        from export2html.branchexporter import BranchExporter

        pagename = u"Страница 1"
        namegenerator = LongNameGenerator(self.root[pagename])
        branchExporter = BranchExporter(self.root[pagename], namegenerator,
                                        Application)

        result = branchExporter.export(outdir=self.outputdir,
                                       imagesonly=False,
                                       alwaysOverwrite=False)

        self.assertEqual(len(result), 0)

        self.assertTrue(os.path.exists(os.path.join(self.outputdir, pagename)))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, pagename + ".html")))
        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, pagename,
                                        "__icon.png")))

        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir, pagename + u"_Страница 2")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir, pagename + u"_Страница 2.html")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir, pagename + u"_Страница 2",
                             "__icon.gif")))

        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir,
                             pagename + u"_Страница 2_Страница 5")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir,
                             pagename + u"_Страница 2_Страница 5.html")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir,
                             pagename + u"_Страница 2_Страница 5",
                             "__icon.gif")))

        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir,
                             pagename + u"_Страница 2_Страница 6")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir,
                             pagename + u"_Страница 2_Страница 6.html")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir,
                             pagename + u"_Страница 2_Страница 6",
                             "__icon.png")))

        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir,
                             pagename + u"_Страница 2_Страница 6_Страница 7")))
        self.assertTrue(
            os.path.exists(
                os.path.join(
                    self.outputdir,
                    pagename + u"_Страница 2_Страница 6_Страница 7.html")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.outputdir,
                             pagename + u"_Страница 2_Страница 6_Страница 7",
                             "__icon.png")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, "__index.html")))
        self.assertTrue(
            os.path.isfile(os.path.join(self.outputdir, "__index.html")))

        self.assertTrue(
            os.path.exists(os.path.join(self.outputdir, PAGE_RESULT_HTML)))
        self.assertTrue(
            os.path.isfile(os.path.join(self.outputdir, PAGE_RESULT_HTML)))