7
7
8
8
import pytest
9
9
from deepdiff import DeepDiff
10
+
10
11
from unstructured_client import UnstructuredClient
11
12
from unstructured_client .models import shared , operations
12
13
from unstructured_client .models .errors import SDKError , ServerError , HTTPValidationError
14
+ from unstructured_client .models .shared .partition_parameters import OutputFormat
13
15
from unstructured_client .utils .retries import BackoffStrategy , RetryConfig
14
16
15
17
@@ -221,3 +223,29 @@ async def call_api():
221
223
uvloop .install ()
222
224
elements = asyncio .run (call_api ())
223
225
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