From 42450ed5e98bd1f7b15133fbe25bbfe23f0b656d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 19 Jul 2026 06:42:18 +0000 Subject: [PATCH] test(epub): add test for BadZipFile exception in extract_epub Adds a new test to `openmed/tests/unit/multimodal/test_epub_extract.py` to verify that `extract_epub` correctly handles an invalid zip file by raising an `UnsupportedDocumentError` with the appropriate message, covering the `zipfile.BadZipFile` except block in `epub.py`. Co-authored-by: zrt219 <199104500+zrt219@users.noreply.github.com> --- openmed/tests/unit/multimodal/test_epub_extract.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openmed/tests/unit/multimodal/test_epub_extract.py b/openmed/tests/unit/multimodal/test_epub_extract.py index ed3d586..b8f8a76 100644 --- a/openmed/tests/unit/multimodal/test_epub_extract.py +++ b/openmed/tests/unit/multimodal/test_epub_extract.py @@ -227,3 +227,11 @@ def test_encrypted_epub_entries_raise(tmp_path: Path): with pytest.raises(UnsupportedDocumentError, match="Encrypted EPUB"): extract_epub(path) + + +def test_epub_bad_zip_file_raises(tmp_path: Path): + path = tmp_path / "bad.epub" + path.write_bytes(b"This is not a zip file.") + + with pytest.raises(UnsupportedDocumentError, match="EPUB must be a valid ZIP archive"): + extract_epub(path)