Esempio n. 1
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. 2
0
    def testCacheLoadPlugins2 (self):
        """
        Проверка на то, что при изменении списка установленных плагинов не работает кэширование
        """
        Application.plugins.clear()
        Application.plugins.load ([u"../plugins/testempty1"])
        Application.plugins.load ([u"../plugins/testempty2"])

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

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

        Application.plugins.clear()

        self.assertFalse (generator.canReadFromCache())
        
        # Перезагрузим плагины в другом порядке
        Application.plugins.load ([u"../plugins/testempty1"])
        Application.plugins.load ([u"../plugins/testempty2"])

        self.assertEqual (len (Application.plugins), 2)
        self.assertTrue (generator.canReadFromCache())
        Application.plugins.clear()
Esempio n. 3
0
    def test_add_tags_01(self):
        text = '''(:org:)
Теги: тег1
        (:orgend:)'''

        self.testPage.content = text

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

        self.assertIn('тег1', self.testPage.tags)
Esempio n. 4
0
    def testResetHash1 (self):
        # Только создали страницу, кешировать нельзя
        generator = HtmlGenerator (self.testPage)
        self.assertFalse (generator.canReadFromCache())

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

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

        generator.resetHash()
        self.assertFalse (generator.canReadFromCache())
Esempio n. 5
0
    def test_add_tags_08(self):
        text = '''(:org:)
    Description: бла-бла-бла
    Теги: -
        (:orgend:)'''

        self.testPage.content = text

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

        self.assertNotIn('-', self.testPage.tags)
Esempio n. 6
0
    def testCacheEmpty (self):
        emptycontent = EmptyContent (Application.config)
        self.testPage.content = u""

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

        # Страница пустая, изменился шаблон для путой записи
        emptycontent.content = u"1111"
        self.assertFalse (generator.canReadFromCache())
        generator.makeHtml (Style().getPageStyle (self.testPage))

        # Изменилось содержимое страницы
        self.testPage.content = u"Бла-бла-бла"
        self.assertFalse (generator.canReadFromCache())
        generator.makeHtml (Style().getPageStyle (self.testPage))

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

        # Изменился шаблон страницы, но страница уже не пустая
        emptycontent.content = u"2222"
        self.assertTrue (generator.canReadFromCache())
Esempio n. 7
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. 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 "Hello world!!!"'
        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 = '''(: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. 10
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. 11
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. 12
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. 13
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. 14
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. 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 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. 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 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. 20
0
    def testCacheSubpages (self):
        """
        Проверка кэширования при добавлении новых подстраниц
        """
        # Только создали страницу, кешировать нельзя
        generator = HtmlGenerator (self.testPage)
        self.assertFalse (generator.canReadFromCache())

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

        # Добавляем новую подстраницу
        WikiPageFactory.create (self.testPage, u"Подстраница 1", [])
        self.assertFalse (generator.canReadFromCache())

        generator.makeHtml (Style().getPageStyle (self.testPage))
        self.assertTrue (generator.canReadFromCache())
Esempio n. 21
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. 22
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. 23
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. 24
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. 25
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. 26
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. 27
0
    def test_add_tags_06(self):
        text = '''(:org:)
    Описание: бла-бла-бла
    Теги: тег 1, тег 2, тег 3

    Описание: бла-бла-бла
    Теги:   тег 4
        (:orgend:)'''

        self.testPage.content = text

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

        self.assertIn('тег 1', self.testPage.tags)
        self.assertIn('тег 2', self.testPage.tags)
        self.assertIn('тег 3', self.testPage.tags)
        self.assertIn('тег 4', self.testPage.tags)
Esempio n. 28
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. 29
0
    def testCacheLoadPlugins1 (self):
        """
        Проверка на то, что при изменении списка установленных плагинов не работает кэширование
        """
        # Только создали страницу, кешировать нельзя
        generator = HtmlGenerator (self.testPage)
        self.assertFalse (generator.canReadFromCache())

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

        # Загрузили плагин. Кэш не должен сработать
        Application.plugins.load ([u"../plugins/testempty1"])
        self.assertFalse (generator.canReadFromCache())

        # Загрузили еще один плагин
        Application.plugins.load ([u"../plugins/testempty2"])
        self.assertFalse (generator.canReadFromCache())
Esempio n. 30
0
    def testConfigFontNameCache (self):
        """
        Тест на то, что на кэширование влияет изменение размера превьюшки по умолчанию
        """
        # Только создали страницу, кешировать нельзя
        generator = HtmlGenerator (self.testPage)
        self.assertFalse (generator.canReadFromCache())

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

        Application.config.set (HtmlRenderConfig.HTML_SECTION, 
                HtmlRenderConfig.FONT_FACE_NAME_PARAM, 
                u"Бла-бла-бла")

        self.assertFalse (generator.canReadFromCache())
        generator.makeHtml (Style().getPageStyle (self.testPage))
        self.assertTrue (generator.canReadFromCache())
Esempio n. 31
0
    def testManySource(self):
        text = u'''(:source lang=python:)
import os

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


(: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 = u".highlight-default .go { color: #888888 } /* Generic.Output */"
        innerString2 = u'        print &quot;Hello world!!!&quot;'
        innerString3 = u'def hello (count):'
        innerString4 = u'       <span class="k">print</span> <span class="s2">&quot;Hello world!!!&quot;</span>'
        innerString5 = u'<span class="kn">import</span> <span class="nn">os</span>'

        self.assertTrue(innerString1 in result)

        # Проверка того, что стиль добавился только один раз
        self.assertTrue(
            result.find(innerString1) == result.rfind(innerString1))

        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
        self.assertTrue(innerString4 in result)
        self.assertTrue(innerString5 in result)
        self.assertFalse(u"(:source" in result)
Esempio n. 32
0
    def testLegend_04(self):
        text = '''(:plot legend=42:)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

        generator = HtmlGenerator(self.page)
        result = generator.makeHtml(Style().getPageStyle(self.page))
        self.assertTrue(
            '"legend": {"enabled": true, "symbolWidth": 60}' in result
            or '"legend": {"symbolWidth": 60, "enabled": true}' in result)
Esempio n. 33
0
    def testAxisMinMax_02(self):
        text = '''(:plot:)
10
20
30
40
(:plotend:)'''

        self.page.content = text

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

        self.assertNotIn('"min"', result)
        self.assertNotIn('"max"', result)
Esempio n. 34
0
    def testCurveColor_01(self):
        text = '''(:plot curve.color="#aabbcc" curve2.color="#001100":)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

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

        self.assertIn('"color": "#aabbcc"', result)
        self.assertIn('"color": "#001100"', result)
Esempio n. 35
0
    def testFullHtml(self):
        text = u"""Бла-бла-бла
(:style:)
body {font-size: 33px}
(:styleend:)
бла-бла-бла
"""
        self.testPage.content = text

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

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

        self.assertTrue(validStyle in result, result)
Esempio n. 36
0
    def testHighlightFileEncoding1(self):
        """
        Явное задание кодировки
        """
        Attachment(self.testPage).attach(
            [os.path.join(self.samplefilesPath, "source_cp1251.cs")])
        content = '(:source file="source_cp1251.cs"  encoding="cp1251":)'
        self.testPage.content = content

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

        self.assertTrue(
            '<span class="k">using</span><span class="w"> </span><span class="nn">System.Collections.Generic</span><span class="p">;</span><span class="w"></span' in result)
        self.assertTrue('Ошибка соединения с сервером' in result)
Esempio n. 37
0
    def testXCol_08 (self):
        text = u'''(:plot curve.xcol="asdfasdf":)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

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

        self.assertNotIn (u'"data"', result)
        self.assertNotIn (u'"series"', result)
Esempio n. 38
0
    def _updatePage(self, page):
        path = page.getHtmlPath()
        cache = HtmlCache(page, self._application)

        # Проверим, можно ли прочитать уже готовый HTML
        if cache.canReadFromCache() and os.path.exists(path):
            return

        style = Style()
        stylepath = style.getPageStyle(page)
        generator = HtmlGenerator(page)

        html = generator.makeHtml(stylepath)
        writeTextFile(path, html)
        cache.saveHash()
Esempio n. 39
0
    def testParentBg1(self):
        text = '(:source lang="python" tabwidth=4:){0}(:sourceend:)'.format(
            self.pythonSource)

        self.testPage.content = text
        self.config.defaultStyle.value = "vim"

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

        innerString1 = ".highlight-vim pre {padding: 0px; border: none; color: inherit; background-color: inherit; margin:0px; }"
        innerString2 = ".highlight-vim {color: inherit; background-color: inherit }"

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 not in result)
Esempio n. 40
0
    def testDefaultStyleVimFile (self):
        text = u'(:source lang="python" tabwidth=4:){0}(:sourceend:)'.format (self.pythonSource)

        self.testPage.content = text

        self.config.defaultStyle.value = "vim"

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

        innerString1 = u".highlight-vim .c"
        innerString2 = u".highlight-vim .c { color: #000080 } /* Comment */"

        self.assertTrue (innerString1 in result)
        self.assertTrue (innerString2 in result)
Esempio n. 41
0
    def testYCol_06(self):
        text = '''(:plot curve.ycol="абырвалг":)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

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

        self.assertNotIn('"data"', result)
        self.assertNotIn('"series"', result)
Esempio n. 42
0
    def testHtmlHead_02(self):
        text = '''(:htmlhead:)
        <meta name="keywords" content="Бла-бла-бла, абырвалг"/>
        <meta name="description" content="Бла-бла-бла абырвалг"/>
(:htmlheadend:)'''

        self.testPage.content = text

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

        self.assertIn(
            '<meta name="keywords" content="Бла-бла-бла, абырвалг"/>', result)
        self.assertIn(
            '<meta name="description" content="Бла-бла-бла абырвалг"/>', result)
        self.assertNotIn("(:htmlhead:)", result)
Esempio n. 43
0
    def testYCol_07(self):
        text = '''(:plot curve.ycol=" 2  ":)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

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

        text = '[0.5, 10.0], [1.5, 20.0], [2.0, 30.0], [4.0, 40.0]'

        self.assertIn(text, result)
Esempio n. 44
0
    def testXCol_02(self):
        text = '''(:plot curve.xcol="  number  ":)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

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

        text = '[0, 10.0], [1, 20.0], [2, 30.0], [3, 40.0]'

        self.assertIn(text, result)
Esempio n. 45
0
    def test_add_tags_04(self):
        text = u'''(:org:)
    Теги: тег 1, тег 2, тег 3
    Теги:   тег 4
        (:orgend:)'''

        self.testPage.content = text

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

        self.assertNotIn(u'тег 1', self.testPage.tags)
        self.assertNotIn(u'тег 2', self.testPage.tags)
        self.assertNotIn(u'тег 3', self.testPage.tags)

        self.assertIn(u'тег 4', self.testPage.tags)
Esempio n. 46
0
    def testData_01(self):
        text = '''(:plot:)
10
20
30
40
(:plotend:)'''

        self.page.content = text

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

        text = '[0, 10.0], [1, 20.0], [2, 30.0], [3, 40.0]'

        self.assertIn(text, result)
Esempio n. 47
0
    def testData_02 (self):
        text = u'''(:plot:)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

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

        text = u'[0.5, 10.0], [1.5, 20.0], [2.0, 30.0], [4.0, 40.0]'

        self.assertIn (text, result)
Esempio n. 48
0
    def testDefaultStyleFile(self):
        Attachment(self.testPage).attach(
            [os.path.join(self.samplefilesPath, "source_utf8.py")])
        text = '(:source lang="python" tabwidth=4 file="source_utf8.py":){0}(:sourceend:)'.format(
            self.pythonSource)

        self.testPage.content = text

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

        innerString1 = ".highlight-default .c"
        innerString2 = ".highlight-default .c { color: #3D7B7B; font-style: italic } /* Comment */"

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
Esempio n. 49
0
    def testXCol_06 (self):
        text = u'''(:plot curve.xcol=2:)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

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

        text = u'[10.0, 10.0], [20.0, 20.0], [30.0, 30.0], [40.0, 40.0]'

        self.assertIn (text, result)
Esempio n. 50
0
    def testAxis_01(self):
        text = '''(:plot:)
10
20
30
40
(:plotend:)'''

        self.page.content = text

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

        text = '"text": null'

        self.assertIn(text, result)
Esempio n. 51
0
    def testCurveStyle_06(self):
        text = '''(:plot curve1.style=auto curve2.style=auto curve3.style=auto:)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

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

        self.assertIn('"dashStyle": "solid"', result)
        self.assertIn('"dashStyle": "longdash"', result)
        self.assertIn('"dashStyle": "shortdash"', result)
Esempio n. 52
0
    def testAxisMinMax_04(self):
        text = '''(:plot x.min="Абырвалг" x.max=-2:)
10
20
30
40
(:plotend:)'''

        self.page.content = text

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

        text1 = '"max": -2.0'

        self.assertIn(text1, result)
        self.assertNotIn('"min"', result)
Esempio n. 53
0
    def testDefaultStyle (self):
        text = u'(: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-default .c"
        innerString2 = u".highlight-default .c { color: #408080; font-style: italic } /* 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>'

        self.assertTrue (innerString1 in result)
        self.assertTrue (innerString2 in result)
        self.assertTrue (innerString3 in result)
        self.assertTrue (innerString4 in result)
Esempio n. 54
0
    def testHighlightFileEncoding3(self):
        """
        Явное задание неправильной кодировки (которой нет в списке кодировок)
        """
        Attachment(self.testPage).attach(
            [os.path.join(self.samplefilesPath, u"source_cp1251.cs")])
        content = u'(:source file="source_cp1251.cs"  encoding="blablabla":)'
        self.testPage.content = content

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

        self.assertTrue(
            u'<span class="k">using</span> <span class="nn">System.Collections.Generic</span><span class="p">;</span>'
            not in result)
        self.assertTrue(u'Ошибка соединения с сервером' not in result)

        self.assertTrue(u'Source' in result)
Esempio n. 55
0
    def testCurves_01(self):
        text = '''(:plot curve2.xcol="number":)
0.5    10
1.5    20
2.0    30
4.0    40
(:plotend:)'''

        self.page.content = text

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

        text1 = '[0.5, 10.0], [1.5, 20.0], [2.0, 30.0], [4.0, 40.0]'
        text2 = '[0, 10.0], [1, 20.0], [2, 30.0], [3, 40.0]'

        self.assertIn(text1, result)
        self.assertIn(text2, result)
Esempio n. 56
0
    def testHighlightFile7(self):
        """
        Явное задание языка для раскраски
        """
        Attachment(self.testPage).attach(
            [os.path.join(self.samplefilesPath, u"source_utf8.py")])
        content = u'(:source file="source_utf8.py" lang="python":)'
        self.testPage.content = content

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

        self.assertTrue(
            u'<span class="kn">import</span> <span class="nn">os.path</span>'
            in result)
        self.assertTrue(
            u'<span class="bp">self</span><span class="o">.</span><span class="n">__correctSysPath</span><span class="p">()</span>'
            in result)
Esempio n. 57
0
    def testStyleVim(self):
        text = '(:source lang="python" tabwidth=4 style="vim":){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>'

        self.assertTrue(innerString1 in result)
        self.assertTrue(innerString2 in result)
        self.assertTrue(innerString3 in result)
        self.assertTrue(innerString4 in result)
Esempio n. 58
0
    def testHighlightFile8(self):
        """
        Нет явного задания языка
        """
        Attachment(self.testPage).attach(
            [os.path.join(self.samplefilesPath, "source_utf8.py")])
        content = '(:source file="source_utf8.py":)'
        self.testPage.content = content

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

        self.assertTrue(
            '<span class="kn">import</span> <span class="nn">os.path</span>' in
            result)
        self.assertTrue(
            '<span class="bp">self</span><span class="o">.</span><span class="n">__correctSysPath</span><span class="p">()</span>'
            in result)
Esempio n. 59
0
    def testAxisTitle_02(self):
        text = '''(:plot x.title="Ось X":)
10
20
30
40
(:plotend:)'''

        self.page.content = text

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

        text1 = '"text": "\\u041e\\u0441\\u044c X"'
        text2 = '"text": null'

        self.assertIn(text1, result)
        self.assertIn(text2, result)
Esempio n. 60
0
    def testAxisMinMax_05(self):
        text = '''(:plot x.min = -2.1 x.max = 2.3:)
10
20
30
40
(:plotend:)'''

        self.page.content = text

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

        text1 = '"min": -2.1'
        text2 = '"max": 2.3'

        self.assertIn(text1, result)
        self.assertIn(text2, result)