diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/attachment_indexation/tests | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/attachment_indexation/tests')
| -rw-r--r-- | addons/attachment_indexation/tests/__init__.py | 3 | ||||
| -rw-r--r-- | addons/attachment_indexation/tests/files/test_content.pdf | bin | 0 -> 7497 bytes | |||
| -rw-r--r-- | addons/attachment_indexation/tests/test_indexation.py | 23 |
3 files changed, 26 insertions, 0 deletions
diff --git a/addons/attachment_indexation/tests/__init__.py b/addons/attachment_indexation/tests/__init__.py new file mode 100644 index 00000000..d76ba919 --- /dev/null +++ b/addons/attachment_indexation/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_indexation diff --git a/addons/attachment_indexation/tests/files/test_content.pdf b/addons/attachment_indexation/tests/files/test_content.pdf Binary files differnew file mode 100644 index 00000000..062e1e6e --- /dev/null +++ b/addons/attachment_indexation/tests/files/test_content.pdf diff --git a/addons/attachment_indexation/tests/test_indexation.py b/addons/attachment_indexation/tests/test_indexation.py new file mode 100644 index 00000000..36c558cd --- /dev/null +++ b/addons/attachment_indexation/tests/test_indexation.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +from odoo.tests.common import TransactionCase, tagged +from unittest import skipIf +import os + +directory = os.path.dirname(__file__) + +try: + from pdfminer.pdfinterp import PDFResourceManager +except ImportError: + PDFResourceManager = None + + +@tagged('post_install', '-at_install') +class TestCaseIndexation(TransactionCase): + + @skipIf(PDFResourceManager is None, "pdfminer not installed") + def test_attachment_pdf_indexation(self): + with open(os.path.join(directory, 'files', 'test_content.pdf'), 'rb') as file: + pdf = file.read() + text = self.env['ir.attachment']._index(pdf, 'application/pdf') + self.assertEqual(text, 'TestContent!!\x0c', 'the index content should be correct') |
