@@ -437,6 +437,35 @@ def test_request_extra_query(self) -> None:
437
437
params = dict (request .url .params )
438
438
assert params == {"foo" : "2" }
439
439
440
+ def test_multipart_repeating_array (self , client : OpenAI ) -> None :
441
+ request = client ._build_request (
442
+ FinalRequestOptions .construct (
443
+ method = "get" ,
444
+ url = "/foo" ,
445
+ headers = {"Content-Type" : "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82" },
446
+ json_data = {"array" : ["foo" , "bar" ]},
447
+ files = [("foo.txt" , b"hello world" )],
448
+ )
449
+ )
450
+
451
+ assert request .read ().split (b"\r \n " ) == [
452
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
453
+ b'Content-Disposition: form-data; name="array[]"' ,
454
+ b"" ,
455
+ b"foo" ,
456
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
457
+ b'Content-Disposition: form-data; name="array[]"' ,
458
+ b"" ,
459
+ b"bar" ,
460
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
461
+ b'Content-Disposition: form-data; name="foo.txt"; filename="upload"' ,
462
+ b"Content-Type: application/octet-stream" ,
463
+ b"" ,
464
+ b"hello world" ,
465
+ b"--6b7ba517decee4a450543ea6ae821c82--" ,
466
+ b"" ,
467
+ ]
468
+
440
469
@pytest .mark .respx (base_url = base_url )
441
470
def test_basic_union_response (self , respx_mock : MockRouter ) -> None :
442
471
class Model1 (BaseModel ):
@@ -1104,6 +1133,35 @@ def test_request_extra_query(self) -> None:
1104
1133
params = dict (request .url .params )
1105
1134
assert params == {"foo" : "2" }
1106
1135
1136
+ def test_multipart_repeating_array (self , async_client : AsyncOpenAI ) -> None :
1137
+ request = async_client ._build_request (
1138
+ FinalRequestOptions .construct (
1139
+ method = "get" ,
1140
+ url = "/foo" ,
1141
+ headers = {"Content-Type" : "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82" },
1142
+ json_data = {"array" : ["foo" , "bar" ]},
1143
+ files = [("foo.txt" , b"hello world" )],
1144
+ )
1145
+ )
1146
+
1147
+ assert request .read ().split (b"\r \n " ) == [
1148
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
1149
+ b'Content-Disposition: form-data; name="array[]"' ,
1150
+ b"" ,
1151
+ b"foo" ,
1152
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
1153
+ b'Content-Disposition: form-data; name="array[]"' ,
1154
+ b"" ,
1155
+ b"bar" ,
1156
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
1157
+ b'Content-Disposition: form-data; name="foo.txt"; filename="upload"' ,
1158
+ b"Content-Type: application/octet-stream" ,
1159
+ b"" ,
1160
+ b"hello world" ,
1161
+ b"--6b7ba517decee4a450543ea6ae821c82--" ,
1162
+ b"" ,
1163
+ ]
1164
+
1107
1165
@pytest .mark .respx (base_url = base_url )
1108
1166
async def test_basic_union_response (self , respx_mock : MockRouter ) -> None :
1109
1167
class Model1 (BaseModel ):
0 commit comments