Exemplo n.º 1
0
    def testHTMLErrors(self):
        ast = modal.ModalLink(None)

        with self.assertLogs(level=logging.ERROR) as cm:
            res = self.render(ast, renderer=base.HTMLRenderer())
        self.assertEqual(len(cm.output), 1)
        self.assertIn("The \'ModalLink\' token requires children", cm.output[0])
Exemplo n.º 2
0
 def testHTML(self):
     ast = modal.ModalLink(None, string='test')
     res = self.render(ast, renderer=base.HTMLRenderer())
     self.assertHTMLTag(res, 'body', size=1)
     self.assertHTMLTag(res(0),
                        'span',
                        size=1,
                        class_='moose-modal-link',
                        string='test')
Exemplo n.º 3
0
    def testMaterializeErrors(self):

        ast = modal.ModalLink(None, content=core.Code(None, content='1+2=3'))
        with self.assertLogs(level=logging.ERROR) as cm:
            res = self.render(ast, renderer=base.MaterializeRenderer())
        self.assertEqual(len(cm.output), 1)
        self.assertIn("The \'ModalLink\' token requires children", cm.output[0])

        ast = modal.ModalLink(None, string='test', content=1980)
        with self.assertLogs(level=logging.ERROR) as cm:
            res = self.render(ast, renderer=base.MaterializeRenderer())
        self.assertEqual(len(cm.output), 1)
        self.assertIn("The \'ModalLink\' token 'content' attribute must be a string or Token", cm.output[0])

        ast = modal.ModalLink(None, string='test')
        with self.assertLogs(level=logging.ERROR) as cm:
            res = self.render(ast, renderer=base.MaterializeRenderer())
        self.assertEqual(len(cm.output), 1)
        self.assertIn("The \'ModalLink\' token 'content' attribute must be a string or Token", cm.output[0])
Exemplo n.º 4
0
    def testMaterialize(self):

        # Content as Token
        ast = modal.ModalLink(None, string='test', content=core.Code(None, content='1+2=3'))
        res = self.render(ast, renderer=base.MaterializeRenderer())
        self.assertSize(res, 2)

        uid = res(1)['id']
        self.assertHTMLTag(res(0), 'a', size=1, href='#{}'.format(uid), string='test')
        self.assertHTMLTag(res(1), 'div', size=1, class_='moose-modal modal', id_=uid)
        self.assertHTMLTag(res(1,0), 'div', size=1, class_='modal-content')
        self.assertHTMLTag(res(1,0,0), 'pre', size=1, class_='moose-pre')
        self.assertHTMLTag(res(1,0,0,0), 'code', size=1, class_='language-text', string='1+2=3')

        # Content as String
        ast = modal.ModalLink(None, string='test', content='1+2=3')
        res = self.render(ast, renderer=base.MaterializeRenderer())
        self.assertSize(res, 2)

        uid = res(1)['id']
        self.assertHTMLTag(res(0), 'a', size=1, href='#{}'.format(uid), string='test')
        self.assertHTMLTag(res(1), 'div', size=1, class_='moose-modal modal', id_=uid)
        self.assertHTMLTag(res(1,0), 'div', size=1, class_='modal-content')
        self.assertHTMLTag(res(1,0,0), 'p', size=1, string='1+2=3')

        # title
        ast = modal.ModalLink(None, string='test', content='1+2=3', title='math')
        res = self.render(ast, renderer=base.MaterializeRenderer())
        self.assertSize(res, 2)

        uid = res(1)['id']
        self.assertHTMLTag(res(0), 'a', size=1, href='#{}'.format(uid), string='test')
        self.assertHTMLTag(res(1), 'div', size=1, class_='moose-modal modal', id_=uid)
        self.assertHTMLTag(res(1,0), 'div', size=2, class_='modal-content')
        self.assertHTMLTag(res(1,0,0), 'h4', size=1, string='math')
        self.assertHTMLTag(res(1,0,1), 'p', size=1, string='1+2=3')
Exemplo n.º 5
0
 def testLatex(self):
     ast = modal.ModalLink(None, string='test')
     res = self.render(ast, renderer=base.LatexRenderer())
     self.assertSize(res, 1)
     self.assertLatexString(res(0), content='test')