test_indexation.py 751 B

123456789101112131415161718192021222324
  1. # -*- coding: utf-8 -*-
  2. from odoo.tests.common import TransactionCase, tagged
  3. from unittest import skipIf
  4. import os
  5. directory = os.path.dirname(__file__)
  6. try:
  7. from pdfminer.pdfinterp import PDFResourceManager
  8. except ImportError:
  9. PDFResourceManager = None
  10. @tagged('post_install', '-at_install')
  11. class TestCaseIndexation(TransactionCase):
  12. @skipIf(PDFResourceManager is None, "pdfminer not installed")
  13. def test_attachment_pdf_indexation(self):
  14. with open(os.path.join(directory, 'files', 'test_content.pdf'), 'rb') as file:
  15. pdf = file.read()
  16. text = self.env['ir.attachment']._index(pdf, 'application/pdf')
  17. self.assertEqual(text, 'TestContent!!\x0c', 'the index content should be correct')