Skip to content

Commit 911138c

Browse files
committed
add test for csv response
1 parent 48fef7a commit 911138c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

_test_unstructured_client/integration/test_integration_freemium.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
import pytest
99
from deepdiff import DeepDiff
10+
1011
from unstructured_client import UnstructuredClient
1112
from unstructured_client.models import shared, operations
1213
from unstructured_client.models.errors import SDKError, ServerError, HTTPValidationError
14+
from unstructured_client.models.shared.partition_parameters import OutputFormat
1315
from 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+
"\nTitle,6aa0ff22f91bbe7e26e8e25ca8052acd,Layout"
251+
)

0 commit comments

Comments
 (0)