def test_indexableContent_pdf(self):
        from Products.CMFCore.CatalogTool import IndexableObjectWrapper
        from Products.CMFDefault.File import File

        pdf_path = os.path.join(_DATA_DIR, 'test.pdf')
        d = File('foo', title='Foo', file=file(pdf_path, 'rb'),
                 content_type='application/pdf')
        d.setLanguage('de')
        try:
            w = IndexableObjectWrapper(ob=d, catalog=None)
        except TypeError:
            w = IndexableObjectWrapper({}, d) # BBB: for CMF < 2.2
        a = self._makeOne(w)

        icc = a.indexableContent(['Title', 'Description'])
        self.assertEqual(icc.getFields(), ['Description', 'Title'])
        self.assertEqual(icc.getFieldData('Title')[0],
                         {'content': u'Foo', 'language': 'de'})
        self.assertEqual(icc.getFieldData('Description')[0],
                         {'content': u'', 'language': 'de'})

        icc = a.indexableContent(['SearchableText'])
        self.assertEqual(icc.getFields(), ['SearchableText'])
        self.assertEqual(icc.getFieldData('SearchableText')[0],
                         {'content': u'Foo', 'language': 'de'})
        self.assertEqual(icc.getFieldData('SearchableText')[1],
                         {'content': u'', 'language': 'de'})
        body = icc.getFieldData('SearchableText')[2]
        self.assertEqual(body['content'].strip(), u'Viel Vögel sprangen artig '
                         u'in den Tüpel und über Feld und Wüste')
        self.assertEqual(body['language'], 'de')
    def test_indexableContent_plain(self):
        from Products.CMFCore.CatalogTool import IndexableObjectWrapper
        from Products.CMFDefault.File import File

        d = File('foo', title='Foo', file='foo content',
                 content_type='text/plain')
        d.setLanguage('en')
        try:
            w = IndexableObjectWrapper(ob=d, catalog=None)
        except TypeError:
            w = IndexableObjectWrapper({}, d) # BBB: for CMF < 2.2
        a = self._makeOne(w)

        icc = a.indexableContent(['Title', 'Description'])
        self.assertEqual(icc.getFields(), ['Description', 'Title'])
        self.assertEqual(icc.getFieldData('Title')[0],
                         {'content': u'Foo', 'language': 'en'})
        self.assertEqual(icc.getFieldData('Description')[0],
                         {'content': u'', 'language': 'en'})

        icc = a.indexableContent(['SearchableText'])
        self.assertEqual(icc.getFields(), ['SearchableText'])
        self.assertEqual(icc.getFieldData('SearchableText')[0],
                         {'content': u'Foo', 'language': 'en'})
        self.assertEqual(icc.getFieldData('SearchableText')[1],
                         {'content': u'', 'language': 'en'})
        self.assertEqual(icc.getFieldData('SearchableText')[2],
                         {'content': u'foo content', 'language': 'en'})