equal
deleted
inserted
replaced
642 '<h1>zou</h1>') |
642 '<h1>zou</h1>') |
643 |
643 |
644 |
644 |
645 def test_printable_value_bytes(self): |
645 def test_printable_value_bytes(self): |
646 with self.admin_access.web_request() as req: |
646 with self.admin_access.web_request() as req: |
647 e = req.create_entity('File', data=Binary('lambda x: 1'), data_format=u'text/x-python', |
647 e = req.create_entity('FakeFile', data=Binary('lambda x: 1'), data_format=u'text/x-python', |
648 data_encoding=u'ascii', data_name=u'toto.py') |
648 data_encoding=u'ascii', data_name=u'toto.py') |
649 from cubicweb import mttransforms |
649 from cubicweb import mttransforms |
650 if mttransforms.HAS_PYGMENTS_TRANSFORMS: |
650 if mttransforms.HAS_PYGMENTS_TRANSFORMS: |
651 import pygments |
651 import pygments |
652 if tuple(int(i) for i in pygments.__version__.split('.')[:2]) >= (1, 3): |
652 if tuple(int(i) for i in pygments.__version__.split('.')[:2]) >= (1, 3): |
661 self.assertEqual(e.printable_value('data'), |
661 self.assertEqual(e.printable_value('data'), |
662 '''<pre class="python"> |
662 '''<pre class="python"> |
663 <span style="color: #C00000;">lambda</span> <span style="color: #000000;">x</span><span style="color: #0000C0;">:</span> <span style="color: #0080C0;">1</span> |
663 <span style="color: #C00000;">lambda</span> <span style="color: #000000;">x</span><span style="color: #0000C0;">:</span> <span style="color: #0080C0;">1</span> |
664 </pre>''') |
664 </pre>''') |
665 |
665 |
666 e = req.create_entity('File', data=Binary('*héhéhé*'), data_format=u'text/rest', |
666 e = req.create_entity('FakeFile', data=Binary('*héhéhé*'), data_format=u'text/rest', |
667 data_encoding=u'utf-8', data_name=u'toto.txt') |
667 data_encoding=u'utf-8', data_name=u'toto.txt') |
668 self.assertEqual(e.printable_value('data'), |
668 self.assertEqual(e.printable_value('data'), |
669 u'<p><em>héhéhé</em></p>') |
669 u'<p><em>héhéhé</em></p>') |
670 |
670 |
671 def test_printable_value_bad_html(self): |
671 def test_printable_value_bad_html(self): |
712 content = soup2xhtml(e.printable_value('content'), 'utf-8') |
712 content = soup2xhtml(e.printable_value('content'), 'utf-8') |
713 self.assertMultiLineEqual(content, u'<div>ms orifice produces weird html</div>') |
713 self.assertMultiLineEqual(content, u'<div>ms orifice produces weird html</div>') |
714 |
714 |
715 def test_fulltextindex(self): |
715 def test_fulltextindex(self): |
716 with self.admin_access.web_request() as req: |
716 with self.admin_access.web_request() as req: |
717 e = self.vreg['etypes'].etype_class('File')(req) |
717 e = self.vreg['etypes'].etype_class('FakeFile')(req) |
718 e.cw_attr_cache['description'] = 'du <em>html</em>' |
718 e.cw_attr_cache['description'] = 'du <em>html</em>' |
719 e.cw_attr_cache['description_format'] = 'text/html' |
719 e.cw_attr_cache['description_format'] = 'text/html' |
720 e.cw_attr_cache['data'] = Binary('some <em>data</em>') |
720 e.cw_attr_cache['data'] = Binary('some <em>data</em>') |
721 e.cw_attr_cache['data_name'] = 'an html file' |
721 e.cw_attr_cache['data_name'] = 'an html file' |
722 e.cw_attr_cache['data_format'] = 'text/html' |
722 e.cw_attr_cache['data_format'] = 'text/html' |