Esempio n. 1
0
    def testSeveralStyles(self):
        text = '''(:source lang="python" tabwidth=4 style="vim":){0}(:sourceend:)

(:source lang="python" tabwidth=4:){0}(:sourceend:)'''.format(self.pythonSource)

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = ".highlight-vim .c"
        innerString2 = ".highlight-vim .c { color: #000080 } /* Comment */"
        innerString3 = '        <span class="nb">print</span> <span class="s2">&quot;Hello world!!!&quot;</span>'
        innerString4 = '<span class="kn">import</span> <span class="nn">os</span>'
        innerString5 = ".highlight-default .c"
        innerString6 = ".highlight-default .c { color: #3D7B7B; font-style: italic } /* Comment */"
        innerString7 = '<div class="highlight-default">'
        innerString8 = '<div class="highlight-vim">'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
        self.assertTrue(innerString4 in result)
        self.assertTrue(innerString5 in result)
        self.assertTrue(innerString6 in result)
        self.assertTrue(innerString7 in result)
        self.assertTrue(innerString8 in result)
Esempio n. 2
0
    def testFullHtmlPython2(self):
        text = u'''(:source lang="python":)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        htmlpath = generator.makeHtml()
        result = self.__readFile(htmlpath)

        innerString1 = u".go { color: #808080 } /* Generic.Output */"
        innerString2 = u'       <span class="k">print</span> <span class="s">&quot;Hello world!!!&quot;</span>'
        innerString3 = u'<span class="kn">import</span> <span class="nn">os</span>'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
Esempio n. 3
0
    def testFullHtmlText2(self):
        text = u'''(:source:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        htmlpath = generator.makeHtml()
        result = self.__readFile(htmlpath)

        innerString1 = u".go { color: #808080 } /* Generic.Output */"
        innerString2 = u'        print &quot;Hello world!!!&quot;'
        innerString3 = u'def hello (count):'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
        self.assertFalse(u"(:source" in result)
Esempio n. 4
0
    def testConfigTabWidth2(self):
        text = u'''(:source tabwidth=10:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''
        self.loader[self.__pluginname].config.tabWidth.value = 4

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        htmlpath = generator.makeHtml()
        result = self.__readFile(htmlpath)

        innerString1 = u".go { color: #808080 } /* Generic.Output */"
        innerString2 = u'          for i in range (10)'
        innerString3 = u'def hello (count):'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
        self.assertFalse(u"(:source" in result)
Esempio n. 5
0
    def testEmpty (self):
        text = u'(:plot:)'

        self.page.content = text

        generator = HtmlGenerator (self.page)
        result = generator.makeHtml (Style().getPageStyle (self.page))

        attachpath = Attachment (self.page).getAttachPath ()

        self.assertIn (u'<div id="graph-0" style="width:700px; height:300px;"></div>', result)
        self.assertIn (u'excanvas.min.js">', result)
        self.assertIn (u'jquery.min.js">', result)
        self.assertIn (u'highcharts.js">', result)
        self.assertIn (u"$('#graph-0').highcharts({", result)

        self.assertTrue (os.path.exists (os.path.join (attachpath,
                                                       u'__thumb',
                                                       u'__js',
                                                       u'excanvas.min.js')))

        self.assertTrue (os.path.exists (os.path.join (attachpath,
                                                       u'__thumb',
                                                       u'__js',
                                                       u'jquery.min.js')))

        self.assertTrue (os.path.exists (os.path.join (attachpath,
                                                       u'__thumb',
                                                       u'__js',
                                                       u'highcharts.js')))
Esempio n. 6
0
    def testHeads_01 (self):
        text = u'''(:htmlhead:)
excanvas.min.js
(:htmlheadend:)
(:plot:)'''

        self.page.content = text

        generator = HtmlGenerator (self.page)
        result = generator.makeHtml (Style().getPageStyle (self.page))

        attachpath = Attachment (self.page).getAttachPath ()

        self.assertIn (u'<div id="graph-0" style="width:700px; height:300px;"></div>', result)

        self.assertNotIn (u'excanvas.min.js">', result)
        self.assertIn (u'jquery.min.js">', result)
        self.assertIn (u'highcharts.js">', result)

        self.assertIn (u"$('#graph-0').highcharts({", result)

        self.assertFalse (os.path.exists (os.path.join (attachpath,
                                                        u'__thumb',
                                                        u'__js',
                                                        u'excanvas.min.js')))

        self.assertTrue (os.path.exists (os.path.join (attachpath,
                                                       u'__thumb',
                                                       u'__js',
                                                       u'jquery.min.js')))

        self.assertTrue (os.path.exists (os.path.join (attachpath,
                                                       u'__thumb',
                                                       u'__js',
                                                       u'highcharts.js')))
Esempio n. 7
0
    def testConfigTabWidth2(self):
        text = u'''(:source tabwidth=10:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''
        self.loader[self.__pluginname].config.tabWidth.value = 4

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        htmlpath = generator.makeHtml ()
        result = self.__readFile (htmlpath)

        innerString1 = u".go { color: #808080 } /* Generic.Output */"
        innerString2 = u'          for i in range (10)'
        innerString3 = u'def hello (count):'
        
        self.assertTrue (innerString1 in result)
        self.assertTrue (innerString2 in result)
        self.assertTrue (innerString3 in result)
        self.assertFalse (u"(:source" in result)
Esempio n. 8
0
    def testFullHtmlText2 (self):
        text = u'''(:source:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        htmlpath = generator.makeHtml ()
        result = self.__readFile (htmlpath)

        innerString1 = u".go { color: #808080 } /* Generic.Output */"
        innerString2 = u'        print &quot;Hello world!!!&quot;'
        innerString3 = u'def hello (count):'
        
        self.assertTrue (innerString1 in result)
        self.assertTrue (innerString2 in result)
        self.assertTrue (innerString3 in result)
        self.assertFalse (u"(:source" in result)
Esempio n. 9
0
    def testFullHtmlPython3 (self):
        # Неправильный размер табуляции
        text = u'''(:source lang="python" tabwidth="qqqqq":)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        htmlpath = generator.makeHtml ()
        result = self.__readFile (htmlpath)

        innerString1 = u".go { color: #808080 } /* Generic.Output */"
        innerString2 = u'       <span class="k">print</span> <span class="s">&quot;Hello world!!!&quot;</span>'
        innerString3 = u'<span class="kn">import</span> <span class="nn">os</span>'
        
        self.assertTrue (innerString1 in result)
        self.assertTrue (innerString2 in result)
        self.assertTrue (innerString3 in result)
Esempio n. 10
0
    def testCacheSubdir (self):
        attach = Attachment (self.testPage)

        # Только создали страницу, кешировать нельзя
        generator = HtmlGenerator (self.testPage)
        self.assertFalse (generator.canReadFromCache())

        generator.makeHtml (Style().getPageStyle (self.testPage))
        # После того, как один раз сгенерили страницу, если ничего не изменилось, можно кешировать
        self.assertTrue (generator.canReadFromCache())

        # Добавим файл в dir
        with open (os.path.join (attach.getAttachPath(), "dir", "temp.tmp"), "w" ) as fp:
            fp.write ("bla-bla-bla")

        self.assertFalse (generator.canReadFromCache())

        # Добавим еще одну вложенную директорию
        subdir = os.path.join (attach.getAttachPath(), "dir", "subdir_2")
        os.mkdir (subdir)
        self.assertFalse (generator.canReadFromCache())

        generator.makeHtml (Style().getPageStyle (self.testPage))

        # Добавим файл в dir/subdir_2
        with open (os.path.join (subdir, "temp2.tmp"), "w" ) as fp:
            fp.write ("bla-bla-bla")

        self.assertFalse (generator.canReadFromCache())
Esempio n. 11
0
    def testFullHtmlText2(self):
        text = '''(:source:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = ".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = '        print &quot;Hello world!!!&quot;'
        innerString3 = 'def hello (count):'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
        self.assertFalse("(:source" in result)
Esempio n. 12
0
    def testFullHtmlText(self):
        text = u'''(:source lang="text" tabwidth=4:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = u".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = u'        print &quot;Hello world!!!&quot;'
        innerString3 = u'def hello (count):'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
        self.assertFalse(u"(:source" in result)
Esempio n. 13
0
    def testFullHtmlPython(self):
        text = u'''(:source lang="python" tabwidth=5:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = u".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = u'          <span class="k">print</span> <span class="s2">&quot;Hello world!!!&quot;</span>'
        innerString3 = u'<span class="kn">import</span> <span class="nn">os</span>'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
Esempio n. 14
0
    def testHeads_01(self):
        text = '''(:htmlhead:)
excanvas.min.js
(:htmlheadend:)
(:plot:)'''

        self.page.content = text

        generator = HtmlGenerator(self.page)
        result = generator.makeHtml(Style().getPageStyle(self.page))

        attachpath = Attachment(self.page).getAttachPath()

        self.assertIn(
            '<div id="graph-0" style="width:700px; height:300px;"></div>',
            result)

        self.assertNotIn('excanvas.min.js">', result)
        self.assertIn('jquery.min.js">', result)
        self.assertIn('highcharts.js">', result)

        self.assertIn("$('#graph-0').highcharts({", result)

        self.assertFalse(
            os.path.exists(
                os.path.join(attachpath, '__thumb', '__js',
                             'excanvas.min.js')))

        self.assertTrue(
            os.path.exists(
                os.path.join(attachpath, '__thumb', '__js', 'jquery.min.js')))

        self.assertTrue(
            os.path.exists(
                os.path.join(attachpath, '__thumb', '__js', 'highcharts.js')))
Esempio n. 15
0
    def testFullHtmlPython (self):
        text = u'''(:source lang="python" tabwidth=5:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        htmlpath = generator.makeHtml (Style().getPageStyle (self.testPage))
        result = self.__readFile (htmlpath)

        innerString1 = u".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = u'          <span class="k">print</span> <span class="s">&quot;Hello world!!!&quot;</span>'
        innerString3 = u'<span class="kn">import</span> <span class="nn">os</span>'
        
        self.assertTrue (innerString1 in result)
        self.assertTrue (innerString2 in result)
        self.assertTrue (innerString3 in result)
Esempio n. 16
0
    def testConfigTabWidth4(self):
        text = u'''(:source:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''
        self.config.tabWidth.value = -1

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        htmlpath = generator.makeHtml (Style().getPageStyle (self.testPage))
        result = self.__readFile (htmlpath)

        innerString1 = u".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = u'    for i in range (10)'
        innerString3 = u'def hello (count):'
        
        self.assertTrue (innerString1 in result)
        self.assertTrue (innerString2 in result)
        self.assertTrue (innerString3 in result)
        self.assertFalse (u"(:source" in result)
Esempio n. 17
0
    def testLineNum1(self):
        text = u'''(:source linenum:)
import os
import os.path
import sys

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''
        self.config.tabWidth.value = 4

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = u""" 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11"""

        self.assertTrue(innerString1 in result)
Esempio n. 18
0
    def testFullHtml2 (self):
        text = u"""Бла-бла-бла
(:style:)
body {font-size: 33px}
(:styleend:)

sdfsdf sdf

(:style:)
body {font-size: 10px}
(:styleend:)

бла-бла-бла
"""
        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        htmlpath = generator.makeHtml (Style().getPageStyle (self.testPage))
        result = self.__readFile (htmlpath)

        validStyle1 = u"<STYLE>body {font-size: 33px}</STYLE>"
        validStyle2 = u"<STYLE>body {font-size: 10px}</STYLE>"

        self.assertTrue (validStyle1 in result, result)
        self.assertTrue (validStyle2 in result, result)
Esempio n. 19
0
    def testFullHtmlInvalidLang (self):
        text = u'''(:source lang="qqq" tabwidth=4:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        htmlpath = generator.makeHtml (Style().getPageStyle (self.testPage))
        result = self.__readFile (htmlpath)

        innerString1 = u".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = u'        print &quot;Hello world!!!&quot;'
        innerString3 = u'def hello (count):'
        
        self.assertTrue (innerString1 in result, result)
        self.assertTrue (innerString2 in result)
        self.assertTrue (innerString3 in result)
        self.assertFalse (u"(:source" in result)
Esempio n. 20
0
    def testFullHtmlPython3(self):
        # Неправильный размер табуляции
        text = '''(:source lang="python" tabwidth="qqqqq":)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = ".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = '       <span class="k">print</span> <span class="s2">&quot;Hello world!!!&quot;</span>'
        innerString3 = '<span class="kn">import</span> <span class="nn">os</span>'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
Esempio n. 21
0
    def testLineNum1(self):
        text = '''(:source linenum:)
import os
import os.path
import sys

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''
        self.config.tabWidth.value = 4

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = """ 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11"""

        self.assertTrue(innerString1 in result)
Esempio n. 22
0
    def testSeveralStyles (self):
        text = u'''(:source lang="python" tabwidth=4 style="vim":){0}(:sourceend:)

(:source lang="python" tabwidth=4:){0}(:sourceend:)'''.format (self.pythonSource)

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        result = generator.makeHtml (Style().getPageStyle (self.testPage))

        innerString1 = u".highlight-vim .c"
        innerString2 = u".highlight-vim .c { color: #000080 } /* Comment */"
        innerString3 = u'        <span class="k">print</span> <span class="s2">&quot;Hello world!!!&quot;</span>'
        innerString4 = u'<span class="kn">import</span> <span class="nn">os</span>'
        innerString5 = u".highlight-default .c"
        innerString6 = u".highlight-default .c { color: #408080; font-style: italic } /* Comment */"
        innerString7 = u'<div class="highlight-default">'
        innerString8 = u'<div class="highlight-vim">'

        self.assertTrue (innerString1 in result)
        self.assertTrue (innerString2 in result)
        self.assertTrue (innerString3 in result)
        self.assertTrue (innerString4 in result)
        self.assertTrue (innerString5 in result)
        self.assertTrue (innerString6 in result)
        self.assertTrue (innerString7 in result)
        self.assertTrue (innerString8 in result)
Esempio n. 23
0
    def testConfigTabWidth3(self):
        text = '''(:source tabwidth="-1":)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''
        self.config.tabWidth.value = 4

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = ".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = '    for i in range (10)'
        innerString3 = 'def hello (count):'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
        self.assertFalse("(:source" in result)
Esempio n. 24
0
    def testConfigTabWidth4(self):
        text = u'''(:source:)
import os

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''
        self.config.tabWidth.value = -1

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = u".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = u'    for i in range (10)'
        innerString3 = u'def hello (count):'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
        self.assertFalse(u"(:source" in result)
Esempio n. 25
0
    def testLineNum1(self):
        text = '''(:source linenum:)
import os
import os.path
import sys

# Комментарий
def hello (count):
	"""
	Hello world
	"""
	for i in range (10):
		print "Hello world!!!"
(:sourceend:)
'''
        self.config.tabWidth.value = 4

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        innerString1 = """<span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>"""

        self.assertTrue(innerString1 in result)
Esempio n. 26
0
    def testHead_01(self):
        text = u'Бла-бла-бла(:head:)Заголовок 1(:headend:)'
        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn(u'Заголовок 1\n</head>', result.replace(u'\r\n', u'\n'))
Esempio n. 27
0
    def testDescription_03(self):
        text = '(:description:)'

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn('<meta name="description" content=""/>', result)
Esempio n. 28
0
    def testHtmlHead_03(self):
        text = '''(:htmlhead:)(:htmlheadend:)'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertNotIn("(:htmlhead:)", result)
Esempio n. 29
0
    def testKeywords_03(self):
        text = '(:keywords:)'

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn('<meta name="keywords" content=""/>', result)
Esempio n. 30
0
    def testEmptyCommand(self):
        text = '''bla-bla-bla (:source:) bla-bla-bla'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertTrue("bla-bla-bla" in result)
Esempio n. 31
0
    def testTitle_02(self):
        text = '(:title    Бла-бла-бла бла-бла   :)'

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn("<title>Бла-бла-бла бла-бла</title>", result)
    def testFooter_01(self):
        text = 'Бла-бла-бла(:footer:)Подвал 1(:footerend:)'
        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn('Бла-бла-бла<br/>\nПодвал 1\n</body>',
                      result.replace('\r\n', '\n'))
Esempio n. 33
0
    def testHead_01(self):
        text = 'Бла-бла-бла(:head:)Заголовок 1(:headend:)'
        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn('Заголовок 1\n</head>',
                      result.replace('\r\n', '\n'))
Esempio n. 34
0
    def testFooter_02(self):
        text = u'Бла-бла-бла(:footer:)Подвал 1(:footerend:)(:footer:)Подвал 2(:footerend:)11111'
        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn(u'Бла-бла-бла11111<br/>\nПодвал 1Подвал 2\n</body>',
                      result.replace(u'\r\n', u'\n'))
Esempio n. 35
0
    def testDescription_03 (self):
        text = u'(:description:)'

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        result = generator.makeHtml (Style().getPageStyle (self.testPage))

        self.assertIn (u'<meta name="description" content=""/>', result)
Esempio n. 36
0
    def testHtmlHead_03 (self):
        text = u'''(:htmlhead:)(:htmlheadend:)'''

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        result = generator.makeHtml (Style().getPageStyle (self.testPage))

        self.assertNotIn ("(:htmlhead:)", result)
Esempio n. 37
0
    def testKeywords_03 (self):
        text = u'(:keywords:)'

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        result = generator.makeHtml (Style().getPageStyle (self.testPage))

        self.assertIn (u'<meta name="keywords" content=""/>', result)
Esempio n. 38
0
    def testFooter_02(self):
        text = 'Бла-бла-бла(:footer:)Подвал 1(:footerend:)(:footer:)Подвал 2(:footerend:)11111'
        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn('Бла-бла-бла11111<br/>\nПодвал 1Подвал 2\n</body>',
                      result.replace('\r\n', '\n'))
Esempio n. 39
0
    def testEmptyCommand(self):
        text = '''bla-bla-bla (:spoiler:) bla-bla-bla'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertTrue("bla-bla-bla" in result)
Esempio n. 40
0
    def testTitle_02 (self):
        text = u'(:title    Бла-бла-бла бла-бла   :)'

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        result = generator.makeHtml (Style().getPageStyle (self.testPage))

        self.assertIn (u"<title>Бла-бла-бла бла-бла</title>", result)
Esempio n. 41
0
    def testStyle_02(self):
        text = '(:style:)   body {color: blue};   (:styleend:)'

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn('''<style>body {color: blue};</style>''', result)
        self.assertNotIn('(:style:)', result)
Esempio n. 42
0
    def testHtmlHead_01 (self):
        text = u'''(:htmlhead:)<meta name="keywords" content="Бла-бла-бла, абырвалг"/>(:htmlheadend:)'''

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        result = generator.makeHtml (Style().getPageStyle (self.testPage))

        self.assertIn (u'<meta name="keywords" content="Бла-бла-бла, абырвалг"/>', result)
        self.assertNotIn ("(:htmlhead:)", result)
Esempio n. 43
0
    def testWikiBoldContent(self):
        text = "бла-бла-бла (:spoiler:)'''Текст'''(:spoilerend:)"

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertTrue("бла-бла-бла" in result)
        self.assertTrue("<b>Текст</b></div></div></div>" in result)
Esempio n. 44
0
    def test_empty(self):
        text = u'''(:org:)(:orgend:)'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn(u'<table', result)
        self.assertEqual(self.testPage.tags, [])
Esempio n. 45
0
    def test_add_tags_09(self):
        text = u'''(:org:)
    Description: бла-бла-бла
        (:orgend:)'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))
        self.assertIn(u'<table', result)
Esempio n. 46
0
    def test_empty(self):
        text = '''(:org:)(:orgend:)'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn('<table', result)
        self.assertEqual(self.testPage.tags, [])
Esempio n. 47
0
    def test_add_tags_09(self):
        text = '''(:org:)
    Description: бла-бла-бла
        (:orgend:)'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))
        self.assertIn('<table', result)
Esempio n. 48
0
    def testHighlightFile5(self):
        Attachment(self.testPage).attach([os.path.join(self.samplefilesPath, u"source_utf8.py")])
        content = u'(:source file="source_utf8.py" lang="text":)(:sourceend:)'
        self.testPage.content = content

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertTrue(u"__correctSysPath()" in result)
        self.assertTrue(u"Плагин, добавляющий обработку команды (:source:) в википарсер" in result)
Esempio n. 49
0
    def testSimple(self):
        text = "бла-бла-бла (:spoiler:)Текст(:spoilerend:)"

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertTrue("бла-бла-бла" in result)
        self.assertTrue("Текст</div></div></div>" in result)
Esempio n. 50
0
    def testCommunity1 (self):
        text = u"бла-бла-бла  (:ljcomm american_gangst:)"

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        result = generator.makeHtml (Style().getPageStyle (self.testPage))

        self.assertTrue (u"бла-бла-бла" in result)
        self.assertTrue (u"""<span class='ljuser ljuser-name_american_gangst' lj:user='******' style='white-space:nowrap'><a href='http://american-gangst.livejournal.com/profile'><img src='http://l-stat.livejournal.com/img/community.gif?v=3' alt='[info]' width='16' height='16' style='vertical-align: bottom; border: 0; padding-right: 1px;'/></a><a href='http://american-gangst.livejournal.com/'><b>american_gangst</b></a></span>""" in result)
Esempio n. 51
0
    def testKeywords_02(self):
        text = u'(:keywords     Бла-бла-бла, абырвалг    :)'

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn(
            u'<meta name="keywords" content="Бла-бла-бла, абырвалг"/>', result)
Esempio n. 52
0
    def testStyle_02(self):
        text = '(:style:)   body {color: blue};   (:styleend:)'

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn('''<style>body {color: blue};</style>''', result)
        self.assertNotIn('(:style:)', result)
Esempio n. 53
0
    def testEmptyCommand (self):
        text = u'''bla-bla-bla (:source:) bla-bla-bla'''

        self.testPage.content = text

        generator = HtmlGenerator (self.testPage)
        htmlpath = generator.makeHtml (Style().getPageStyle (self.testPage))
        result = self.__readFile (htmlpath)

        self.assertTrue (u"bla-bla-bla" in result)
Esempio n. 54
0
    def testEmptyCommand(self):
        text = u'''bla-bla-bla (:source:) bla-bla-bla'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        htmlpath = generator.makeHtml()
        result = self.__readFile(htmlpath)

        self.assertTrue(u"bla-bla-bla" in result)
Esempio n. 55
0
    def testDescription_02(self):
        text = '(:description    Бла-бла-бла абырвалг   :)'

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn(
            '<meta name="description" content="Бла-бла-бла абырвалг"/>', result)
Esempio n. 56
0
    def testKeywords_01(self):
        text = '(:keywords Бла-бла-бла, абырвалг:)'

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn(
            '<meta name="keywords" content="Бла-бла-бла, абырвалг"/>', result)
Esempio n. 57
0
    def test_add_tags_01(self):
        text = u'''(:org:)
Теги: тег1
        (:orgend:)'''

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertIn(u'тег1', self.testPage.tags)
Esempio n. 58
0
    def testHighlightFile10(self):
        """
        Проверка случая, если прикрепленного с заданным именем файла нет
        """
        content = '(:source file="source_utf8111.py" lang="text":)'
        self.testPage.content = content

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertTrue('source_utf8111.py' in result, result)
Esempio n. 59
0
    def testCollapseText(self):
        text = """бла-бла-бла (:spoiler collapsetext="Скукожить":)Текст(:spoilerend:)"""

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertTrue("бла-бла-бла" in result)
        self.assertTrue("Текст</div></div></div>" in result)
        self.assertTrue("Скукожить</a>" in result)
Esempio n. 60
0
    def testExpandText(self):
        text = """бла-бла-бла (:spoiler expandtext="Раскукожить":)Текст(:spoilerend:)"""

        self.testPage.content = text

        generator = HtmlGenerator(self.testPage)
        result = generator.makeHtml(Style().getPageStyle(self.testPage))

        self.assertTrue("бла-бла-бла" in result)
        self.assertTrue("Текст</div></div></div>" in result)
        self.assertTrue("Раскукожить</a></span></div>" in result)