From ad707ad4af61eaf9577066212e60ac2cef3e21b1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 Mar 2025 09:08:17 +0530 Subject: [PATCH] Add a test for FTS indexing of archives --- src/calibre/db/tests/fts.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/db/tests/fts.py b/src/calibre/db/tests/fts.py index 8690888c83..32fbf3ead9 100644 --- a/src/calibre/db/tests/fts.py +++ b/src/calibre/db/tests/fts.py @@ -193,7 +193,7 @@ class FTSTest(BaseTest): # }}} - def test_pdftotext(self): + def test_fts_indexing(self): pdf_data = '''\ %PDF-1.1 %¥±ë @@ -257,8 +257,13 @@ startxref pdf = os.path.join(tdir, 'test.pdf') with open(pdf, 'w') as f: f.write(pdf_data) - from calibre.db.fts.text import pdftotext - self.assertEqual(pdftotext(pdf).strip(), 'Hello World') + from calibre.db.fts.text import extract_text + self.assertEqual(extract_text(pdf).strip(), 'Hello World') + from zipfile import ZipFile + zip = os.path.join(tdir, 'test.zip') + with ZipFile(zip, 'w') as zf: + zf.writestr('text.pdf', pdf_data) + self.assertEqual(extract_text(zip).strip(), 'Hello World') def find_tests():