55import pytest
66from pypdf import PdfReader
77
8- from unstructured_client ._hooks .custom .pdf_utils import check_pdf , PDFValidationError
8+ from unstructured_client ._hooks .custom .pdf_utils import check_pdf , read_pdf , PDFValidationError
99from _test_unstructured_client .unit_utils import sample_docs_path
1010
1111
@@ -23,15 +23,6 @@ def test_check_pdf_with_valid_pdf():
2323 assert isinstance (result , PdfReader )
2424
2525
26- # TODO(klaijan)
27- def test_check_pdf_with_valid_pdf_multipart ():
28- pdf_path = sample_docs_path ("valid-multipart-wrapped.pdf" )
29- pdf = _open_pdf (pdf_path )
30-
31- result = check_pdf (pdf )
32- assert isinstance (result , PdfReader )
33-
34-
3526@pytest .mark .parametrize (
3627 ("pdf_name" , "expected_error_message" ),
3728 [
@@ -47,6 +38,13 @@ def test_check_pdf_with_valid_pdf_multipart():
4738 "failing-missing-pages.pdf" ,
4839 "File does not appear to be a valid PDF. Error: Invalid object in /Pages" ,
4940 ),
41+ # TODO(klaijan) - add pdf file when file is ready
42+ """
43+ (
44+ ".pdf",
45+ "File does not appear to be a valid PDF. Error: Cannot find Root object in pdf"
46+ )
47+ """
5048 ],
5149)
5250def test_check_pdf_raises_pdf_validation_error (
@@ -60,3 +58,15 @@ def test_check_pdf_raises_pdf_validation_error(
6058 check_pdf (pdf )
6159
6260 assert exc_info .value .message == expected_error_message
61+
62+
63+ # TODO(klaijan) - uncomment when file is ready
64+ """
65+ def test_check_read_pdf():
66+ pdf_path = sample_docs_path(".pdf")
67+ with open(pdf_path, "rb") as f:
68+ pdf_content = f.read()
69+ pdf = read_pdf(pdf_content)
70+ result = check_pdf(pdf)
71+ assert isinstance(result, PdfReader)
72+ """
0 commit comments