77
88import pytest
99from deepdiff import DeepDiff
10+
1011from unstructured_client import UnstructuredClient
1112from unstructured_client .models import shared , operations
1213from unstructured_client .models .errors import SDKError , ServerError , HTTPValidationError
14+ from unstructured_client .models .shared .partition_parameters import OutputFormat
1315from unstructured_client .utils .retries import BackoffStrategy , RetryConfig
1416
1517
@@ -221,3 +223,29 @@ async def call_api():
221223 uvloop .install ()
222224 elements = asyncio .run (call_api ())
223225 assert len (elements ) > 0
226+
227+
228+ def test_partition_csv_response (client , doc_path ):
229+ filename = "layout-parser-paper-fast.pdf"
230+ with open (doc_path / filename , "rb" ) as f :
231+ files = shared .Files (
232+ content = f .read (),
233+ file_name = filename ,
234+ )
235+
236+ req = operations .PartitionRequest (
237+ partition_parameters = shared .PartitionParameters (
238+ files = files ,
239+ output_format = OutputFormat .TEXT_CSV ,
240+ )
241+ )
242+
243+ response = client .general .partition (request = req )
244+ assert response .status_code == 200
245+ assert response .content_type == "text/csv; charset=utf-8"
246+ assert response .elements is None
247+ assert response .csv_elements is not None
248+ assert response .csv_elements .startswith (
249+ "type,element_id,text,filetype,languages,page_number,filename,parent_id"
250+ "\n Title,6aa0ff22f91bbe7e26e8e25ca8052acd,Layout"
251+ )
0 commit comments