été'
self.assertEqual(tidy(e.printable_value('content')),
- u"C'est un exemple sérieux")
+ u'été
')
+ e.cw_attr_cache['content'] = u'C'est un exemple sérieux'
+ self.assertEqual(tidy(e.printable_value('content')),
+ u"C'est un exemple sérieux")
# make sure valid xhtml is left untouched
- e['content'] = u'
'
- self.assertEqual(e.printable_value('content'), e['content'])
- e['content'] = u'
'
- self.assertEqual(e.printable_value('content'), e['content'])
- e['content'] = u'été'
- self.assertEqual(e.printable_value('content'), e['content'])
- e['content'] = u'hop\r\nhop\nhip\rmomo'
+ e.cw_attr_cache['content'] = u'
'
+ self.assertEqual(e.printable_value('content'), e.cw_attr_cache['content'])
+ e.cw_attr_cache['content'] = u'
'
+ self.assertEqual(e.printable_value('content'), e.cw_attr_cache['content'])
+ e.cw_attr_cache['content'] = u'été'
+ self.assertEqual(e.printable_value('content'), e.cw_attr_cache['content'])
+ e.cw_attr_cache['content'] = u'hop\r\nhop\nhip\rmomo'
self.assertEqual(e.printable_value('content'), u'hop\nhop\nhip\nmomo')
def test_printable_value_bad_html_ms(self):
- self.skipTest('fix soup2xhtml to handle this test')
req = self.request()
e = req.create_entity('Card', title=u'bad html', content=u'
R&D
',
content_format=u'text/html')
tidy = lambda x: x.replace('\n', '')
- e['content'] = u'
ms orifice produces weird html
'
- self.assertEqual(tidy(e.printable_value('content')),
- u'
ms orifice produces weird html
')
- import tidy as tidymod # apt-get install python-tidy
- tidy = lambda x: str(tidymod.parseString(x.encode('utf-8'),
- **{'drop_proprietary_attributes': True,
- 'output_xhtml': True,
- 'show_body_only' : True,
- 'quote-nbsp' : False,
- 'char_encoding' : 'utf8'})).decode('utf-8').strip()
- self.assertEqual(tidy(e.printable_value('content')),
- u'
ms orifice produces weird html
')
-
+ e.cw_attr_cache['content'] = u'
ms orifice produces weird html
'
+ # Caution! current implementation of soup2xhtml strips first div element
+ content = soup2xhtml(e.printable_value('content'), 'utf-8')
+ self.assertMultiLineEqual(content, u'
ms orifice produces weird html
')
def test_fulltextindex(self):
e = self.vreg['etypes'].etype_class('File')(self.request())
- e['description'] = 'du
html'
- e['description_format'] = 'text/html'
- e['data'] = Binary('some
data')
- e['data_name'] = 'an html file'
- e['data_format'] = 'text/html'
- e['data_encoding'] = 'ascii'
+ e.cw_attr_cache['description'] = 'du
html'
+ e.cw_attr_cache['description_format'] = 'text/html'
+ e.cw_attr_cache['data'] = Binary('some
data')
+ e.cw_attr_cache['data_name'] = 'an html file'
+ e.cw_attr_cache['data_format'] = 'text/html'
+ e.cw_attr_cache['data_encoding'] = 'ascii'
e._cw.transaction_data = {} # XXX req should be a session
self.assertEqual(e.cw_adapt_to('IFTIndexable').get_words(),
- {'C': [u'du', u'html', 'an', 'html', 'file', u'some', u'data']})
+ {'C': ['an', 'html', 'file', 'du', 'html', 'some', 'data']})
def test_nonregr_relation_cache(self):
@@ -461,7 +451,7 @@
'WHERE U login "admin", S1 name "activated", S2 name "deactivated"')[0][0]
trinfo = self.execute('Any X WHERE X eid %(x)s', {'x': eid}).get_entity(0, 0)
trinfo.complete()
- self.failUnless(isinstance(trinfo['creation_date'], datetime))
+ self.failUnless(isinstance(trinfo.cw_attr_cache['creation_date'], datetime))
self.failUnless(trinfo.cw_relation_cached('from_state', 'subject'))
self.failUnless(trinfo.cw_relation_cached('to_state', 'subject'))
self.failUnless(trinfo.cw_relation_cached('wf_info_for', 'subject'))
@@ -499,7 +489,7 @@
self.assertEqual(card3.rest_path(), 'card/eid/%d' % card3.eid)
card4 = req.create_entity('Card', title=u'pod', wikiid=u'zo?bi')
self.assertEqual(card4.rest_path(), 'card/eid/%d' % card4.eid)
-
+
def test_set_attributes(self):
req = self.request()
@@ -515,7 +505,7 @@
req = self.request()
note = req.create_entity('Note', type=u'z')
metainf = note.cw_metainformation()
- self.assertEqual(metainf, {'source': {'adapter': 'native', 'uri': 'system'}, 'type': u'Note', 'extid': None})
+ self.assertEqual(metainf, {'source': {'type': 'native', 'uri': 'system'}, 'type': u'Note', 'extid': None})
self.assertEqual(note.absolute_url(), 'http://testing.fr/cubicweb/note/%s' % note.eid)
metainf['source'] = metainf['source'].copy()
metainf['source']['base-url'] = 'http://cubicweb2.com/'