Exemplo n.º 1
0
 def testReinit(self):
     ast = tokens.Paragraph(None)
     comp = ParComponent()
     content = page.PageNodeBase(None)
     renderer = renderers.HTMLRenderer()
     translator = Translator(content, MarkdownReader(), renderer, [])
     translator.init('')
     renderer.add(tokens.Paragraph, comp)
     renderer.render(ast)
     renderer.render(ast)
     self.assertEqual(comp.count, 2)
Exemplo n.º 2
0
    def testProcess(self):
        ast = tokens.Paragraph(None)
        tokens.String(ast, content=u'foo')

        renderer = renderers.HTMLRenderer()
        renderer.add(tokens.Paragraph, ParComponent())
        renderer.add(tokens.String, StringComponent())

        root = html.Tag(None, 'div')
        renderer.process(root, ast)

        self.assertIsInstance(root(0), html.Tag)
        self.assertEqual(root(0).name, 'p')
        self.assertIsInstance(root(0)(0), html.String)
        self.assertEqual(root(0)(0).content, u'foo')
Exemplo n.º 3
0
    def testRender(self):
        ast = tokens.Paragraph(None)
        tokens.String(ast, content=u'foo')
        content = page.PageNodeBase(None)
        renderer = renderers.HTMLRenderer()
        translator = Translator(content, MarkdownReader(), renderer, [])
        translator.init('')

        renderer.add(tokens.Paragraph, ParComponent())
        renderer.add(tokens.String, StringComponent())

        root = renderer.render(ast)
        self.assertIsInstance(root, html.Tag)
        self.assertEqual(root.name, 'body')
        self.assertIsInstance(root(0), html.Tag)
        self.assertEqual(root(0).name, 'p')
        self.assertIsInstance(root(0)(0), html.String)
        self.assertEqual(root(0)(0).content, u'foo')
Exemplo n.º 4
0
 def testProcessWithUnlistedToken(self):
     renderer = renderers.HTMLRenderer()
     root = html.Tag(None, 'div')
     renderer.process(root, tokens.Token(None))
     self.assertEqual(len(root), 0)
Exemplo n.º 5
0
    def testMissingCompomentMethod(self):
        renderer = renderers.HTMLRenderer()

        with self.assertRaises(exceptions.MooseDocsException) as e:
            renderer.add(tokens.Paragraph, BadComponent())
        self.assertIn("does not have a createHTML method", e.exception.message)