def test_simple_extraction(self):
     self.layer['portal'].invokeFactory(type_name='Document',
                                        id='document',
                                        text='Foo bar baz')
     doc = self.layer['portal'].document
     adapter = ITextExtractor(doc)
     self.assertEqual(adapter.text, 'Foo bar baz')
 def test_html_extraction(self):
     self.layer['portal'].invokeFactory(
         type_name='Document',
         id='document',
         text='<p>Foo <strong>bar</strong> baz</p>')
     doc = self.layer['portal'].document
     adapter = ITextExtractor(doc)
     self.assertEqual(adapter.text, 'Foo bar baz')
Exemple #3
0
 def safe_call(self):
     try:
         adapter = ITextExtractor(self.context)
     except ComponentLookupError:
         return None
     if adapter.text:
         return "\n".join([l.strip() for l in adapter.text.splitlines()])
     return ""
 def test_invalid_object(self):
     obj = 31
     adapter = ITextExtractor(obj)
     self.assertEqual(adapter.text, '')
 def test_invalid_text_info(self):
     obj = Foo()
     obj.text = 5
     adapter = ITextExtractor(obj)
     self.assertEqual(adapter.text, '')
 def test_pacomment_text(self):
     obj = Foo()
     obj.text = 'Foo bar baz'
     adapter = ITextExtractor(obj)
     self.assertEqual(adapter.text, 'Foo bar baz')
 def test_pacomment_text(self):
     comment = Comment()
     comment.text = u'Foo bar baz'
     adapter = ITextExtractor(comment)
     self.assertEqual(adapter.text, 'Foo bar baz')