22
33import tempfile
44from pathlib import Path
5+ from typing import Literal
56
67import httpx
78import json
1516from unstructured_client import UnstructuredClient
1617from unstructured_client .models import shared , operations
1718from unstructured_client .models .errors import HTTPValidationError
19+ from unstructured_client .models .shared .partition_parameters import Strategy
1820from unstructured_client .utils .retries import BackoffStrategy , RetryConfig
1921from unstructured_client ._hooks .custom import form_utils
2022from unstructured_client ._hooks .custom import split_pdf_hook
@@ -106,8 +108,8 @@ def test_integration_split_pdf_has_same_output_as_non_split(
106108 assert len (diff ) == 0
107109
108110@pytest .mark .parametrize ( ("filename" , "expected_ok" , "strategy" ), [
109- ("_sample_docs/layout-parser-paper.pdf" , True , "hi_res" ), # 16
110- ]# pages
111+ ("_sample_docs/layout-parser-paper.pdf" , True , shared . Strategy . HI_RES ), # 16 pages
112+ ]
111113)
112114@pytest .mark .parametrize ( ("use_caching" , "cache_dir" ), [
113115 (True , None ), # Use default cache dir
@@ -116,8 +118,11 @@ def test_integration_split_pdf_has_same_output_as_non_split(
116118 (False , Path (tempfile .gettempdir ()) / "test_integration_unstructured_client2" ), # Don't use caching, use custom cache dir
117119])
118120def test_integration_split_pdf_with_caching (
119- filename : str , expected_ok : bool , strategy : str , use_caching : bool ,
120- cache_dir : Path | None
121+ filename : str ,
122+ expected_ok : bool ,
123+ strategy : Literal [Strategy .HI_RES ],
124+ use_caching : bool ,
125+ cache_dir : Path | None ,
121126):
122127 try :
123128 response = requests .get ("http://localhost:8000/general/docs" )
@@ -143,7 +148,7 @@ def test_integration_split_pdf_with_caching(
143148 languages = ["eng" ],
144149 split_pdf_page = True ,
145150 split_pdf_cache_tmp_data = use_caching ,
146- split_pdf_cache_dir = cache_dir ,
151+ split_pdf_cache_tmp_data_dir = str ( cache_dir ) ,
147152 )
148153
149154 req = operations .PartitionRequest (
0 commit comments