@@ -114,7 +114,7 @@ async def test_incorrect_upstream_url(aioresponses: aioresponses):
114
114
115
115
116
116
@pytest .mark .asyncio
117
- async def test_asdasd (aioresponses : aioresponses ):
117
+ async def test_incorrect_format (aioresponses : aioresponses ):
118
118
aioresponses .post (
119
119
"http://localhost:5001/openai/deployments/gpt-4/chat/completions?api-version=2023-03-15-preview" ,
120
120
status = 400 ,
@@ -134,3 +134,46 @@ async def test_asdasd(aioresponses: aioresponses):
134
134
assert response .status_code == 400
135
135
136
136
assert response .content == b"Incorrect format"
137
+
138
+
139
+ @pytest .mark .asyncio
140
+ async def test_incorrect_streaming_request (aioresponses : aioresponses ):
141
+ aioresponses .post (
142
+ "http://localhost:5001/openai/deployments/gpt-4/chat/completions?api-version=2023-03-15-preview" ,
143
+ status = 400 ,
144
+ body = json .dumps (
145
+ {
146
+ "error" : {
147
+ "message" : "0 is less than the minimum of 1 - 'n'" ,
148
+ "type" : "invalid_request_error" ,
149
+ "param" : None ,
150
+ "code" : None ,
151
+ }
152
+ }
153
+ ),
154
+ content_type = "application/json" ,
155
+ )
156
+ test_app = AsyncClient (app = app , base_url = "http://test.com" )
157
+
158
+ response = await test_app .post (
159
+ "/openai/deployments/gpt-4/chat/completions" ,
160
+ json = {
161
+ "messages" : [{"role" : "user" , "content" : "Test content" }],
162
+ "stream" : True ,
163
+ "n" : 0 ,
164
+ },
165
+ headers = {
166
+ "X-UPSTREAM-KEY" : "TEST_API_KEY" ,
167
+ "X-UPSTREAM-ENDPOINT" : "http://localhost:5001/openai/deployments/gpt-4/chat/completions" ,
168
+ },
169
+ )
170
+
171
+ assert response .status_code == 400
172
+ assert response .json () == {
173
+ "error" : {
174
+ "message" : "0 is less than the minimum of 1 - 'n'" ,
175
+ "type" : "invalid_request_error" ,
176
+ "param" : None ,
177
+ "code" : None ,
178
+ }
179
+ }
0 commit comments