mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Only getting PDF title's once.
This commit is contained in:
parent
58a4dfa335
commit
3881d0fd9d
2 changed files with 8 additions and 1 deletions
|
|
@ -29,7 +29,8 @@ def model_pdf(groups: Dict[str, List[File]], _: Session):
|
|||
logger.warning(f'Cannot get title from PDF without PyPDF2')
|
||||
return
|
||||
|
||||
pdf_files = (file for group in groups.values() for file in group if file.mimetype == 'application/pdf')
|
||||
pdf_files = (file for group in groups.values() for file in group if
|
||||
file.indexed is not True and file.mimetype == 'application/pdf')
|
||||
|
||||
for file in pdf_files:
|
||||
path: pathlib.Path = file.path.path if hasattr(file.path, 'path') else file.path
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from wrolpi.files.lib import refresh_files
|
||||
|
|
@ -9,5 +11,9 @@ async def test_pdf_title(test_session, example_pdf):
|
|||
"""PDF modeler extracts the PDF's title."""
|
||||
await refresh_files()
|
||||
|
||||
with mock.patch('wrolpi.files.pdfs.get_pdf_title') as mock_get_pdf_title:
|
||||
mock_get_pdf_title.side_effect = Exception('should not be read again')
|
||||
await refresh_files()
|
||||
|
||||
pdf: File = test_session.query(File).one()
|
||||
assert pdf.title == 'WROLPi Test PDF'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue