equal
deleted
inserted
replaced
2 """unit tests for cubicweb.web.views.entities module""" |
2 """unit tests for cubicweb.web.views.entities module""" |
3 |
3 |
4 from cubicweb.devtools.apptest import EnvBasedTC |
4 from cubicweb.devtools.apptest import EnvBasedTC |
5 |
5 |
6 from mx.DateTime import DateTimeType, now |
6 from mx.DateTime import DateTimeType, now |
|
7 |
7 from cubicweb import Binary |
8 from cubicweb import Binary |
|
9 from cubicweb.common.mttransforms import HAS_TAL |
8 |
10 |
9 class EntityTC(EnvBasedTC): |
11 class EntityTC(EnvBasedTC): |
10 |
12 |
11 ## def setup_database(self): |
13 ## def setup_database(self): |
12 ## self.add_entity('Personne', nom=u'di mascio', prenom=u'adrien') |
14 ## self.add_entity('Personne', nom=u'di mascio', prenom=u'adrien') |
299 e['content'] = 'du *texte*' |
301 e['content'] = 'du *texte*' |
300 e['content_format'] = 'text/plain' |
302 e['content_format'] = 'text/plain' |
301 self.assertEquals(e.printable_value('content'), |
303 self.assertEquals(e.printable_value('content'), |
302 '<p>\ndu *texte*\n</p>') |
304 '<p>\ndu *texte*\n</p>') |
303 e['title'] = 'zou' |
305 e['title'] = 'zou' |
304 e['content'] = '<h1 tal:content="self/title">titre</h1>' |
|
305 e['content_format'] = 'text/cubicweb-page-template' |
|
306 self.assertEquals(e.printable_value('content'), |
|
307 '<h1>zou</h1>') |
|
308 |
|
309 #e = self.etype_instance('Task') |
306 #e = self.etype_instance('Task') |
310 e['content'] = '''\ |
307 e['content'] = '''\ |
311 a title |
308 a title |
312 ======= |
309 ======= |
313 du :eid:`1:*ReST*`''' |
310 du :eid:`1:*ReST*`''' |
317 |
314 |
318 e['content'] = u'<b>yo (zou éà ;)</b>' |
315 e['content'] = u'<b>yo (zou éà ;)</b>' |
319 e['content_format'] = 'text/html' |
316 e['content_format'] = 'text/html' |
320 self.assertEquals(e.printable_value('content', format='text/plain').strip(), |
317 self.assertEquals(e.printable_value('content', format='text/plain').strip(), |
321 u'**yo (zou éà ;)**') |
318 u'**yo (zou éà ;)**') |
|
319 if HAS_TAL: |
|
320 e['content'] = '<h1 tal:content="self/title">titre</h1>' |
|
321 e['content_format'] = 'text/cubicweb-page-template' |
|
322 self.assertEquals(e.printable_value('content'), |
|
323 '<h1>zou</h1>') |
|
324 |
322 |
325 |
323 def test_printable_value_bytes(self): |
326 def test_printable_value_bytes(self): |
324 e = self.add_entity('File', data=Binary('lambda x: 1'), data_format=u'text/x-python', |
327 e = self.add_entity('File', data=Binary('lambda x: 1'), data_format=u'text/x-python', |
325 data_encoding=u'ascii', name=u'toto.py') |
328 data_encoding=u'ascii', name=u'toto.py') |
326 from cubicweb.common import mttransforms |
329 from cubicweb.common import mttransforms |