diff options
| author | len-odoo <len@odoo.com> | 2020-01-28 11:16:55 +0000 |
|---|---|---|
| committer | Thanh Dodeur <tso@odoo.com> | 2020-01-29 10:26:46 +0000 |
| commit | 183af97168f38d4be20236dff76beecd8f009447 (patch) | |
| tree | b4e7bb7c9225a1421b368062fb4a064bf4eefada /addons/attachment_indexation/tests | |
| parent | b3661017d04cad3d9fc93c1d16ddb81e4744e603 (diff) | |
[IMP] attachment_indexation: improved PDF text extraction
PyPDF performs badly on many types of PDF documents.
We add a text extraction with pdfminer, which is designed for this task.
Because pdf content extraction was so flaky, it was completely
deactivated by 1b753b0d53744a6e. We revert that :-)
closes odoo/odoo#38508
Task: 2152494
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
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 | 16 |
3 files changed, 19 insertions, 0 deletions
diff --git a/addons/attachment_indexation/tests/__init__.py b/addons/attachment_indexation/tests/__init__.py new file mode 100644 index 00000000000..d76ba91978d --- /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 00000000000..062e1e6e2f6 --- /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 00000000000..9f5fa0eca15 --- /dev/null +++ b/addons/attachment_indexation/tests/test_indexation.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from odoo.tests.common import TransactionCase, tagged +import os + +directory = os.path.dirname(__file__) + + +@tagged('post_install', '-at_install') +class TestCaseIndexation(TransactionCase): + + 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') |
