11from __future__ import annotations
22
3+ import json
4+ import pytest
5+
36from unstructured_client ._hooks .custom .request_utils import create_response
47
58
@@ -14,10 +17,12 @@ def test_create_response_for_json():
1417 assert response .headers ["Content-Type" ] == "application/json"
1518
1619def test_create_response_for_csv ():
17- elements = 'type,element_id,text,languages,page_number,filename,filetype,parent_id' \
18- '\n Title,f73329878fbbb0bb131a83e7b6daacbe,Module One - Introduction to Product' \
19- ' Development and Quality Assurance,[\' eng\' ],1,list-item-example-1.pdf,application/pdf,'
20+ elements = [
21+ b'type,element_id,text,languages,page_number,filename,filetype,parent_id' \
22+ b'\n Title,f73329878fbbb0bb131a83e7b6daacbe,Module One - Introduction to Product' \
23+ b' Development and Quality Assurance,[\' eng\' ],1,list-item-example-1.pdf,application/pdf,'
24+ ]
2025 response = create_response (elements )
2126 assert response .status_code == 200
22- assert response .json () == None
23- assert response .headers ["Content-Type" ] == "text/csv"
27+ pytest . raises ( json . decoder . JSONDecodeError , response .json )
28+ assert response .headers ["Content-Type" ] == "text/csv; charset=utf-8 "
0 commit comments