Skip to content

Commit 6a54f96

Browse files
committed
Fix tests added from rebase broken by QueryResult type change
1 parent 32dab76 commit 6a54f96

4 files changed

Lines changed: 29 additions & 18 deletions

File tree

src/inference_endpoint/core/types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ def __post_init__(self):
137137
msgspec.structs.force_setattr(
138138
self, "response_output", tuple(self.response_output)
139139
)
140+
elif isinstance(self.response_output, dict):
141+
for k, v in self.response_output.items():
142+
if isinstance(v, list):
143+
self.response_output[k] = tuple(v)
140144

141145

142146
class StreamChunk(msgspec.Struct, tag="stream_chunk", kw_only=True):

tests/integration/endpoint_client/test_http_client_streaming.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ async def test_streaming_with_futures(self, mock_http_echo_server, tmp_path):
130130
assert result.response_output == f"Non-streaming request {idx}"
131131
else:
132132
assert result.id == f"stream-{idx}"
133+
assert list(result.response_output.keys()) == ["output"]
133134
assert (
134-
"Streaming" in result.response_output
135-
or result.response_output == f"Streaming request {idx}"
135+
"".join(result.response_output["output"])
136+
== f"Streaming request {idx}"
136137
)
137138

138139
finally:
@@ -194,7 +195,10 @@ async def test_mixed_streaming_non_streaming(self, futures_http_client):
194195
]
195196
else:
196197
# Streaming response
197-
assert "".join(result.response_output) == "Streaming response test"
198+
assert (
199+
"".join(result.response_output["output"])
200+
== "Streaming response test"
201+
)
198202

199203
@pytest.mark.asyncio
200204
async def test_concurrent_streaming_requests(self, futures_http_client):
@@ -224,7 +228,7 @@ async def test_concurrent_streaming_requests(self, futures_http_client):
224228
for idx, result in results:
225229
assert result.id == f"concurrent-stream-{idx}"
226230
assert (
227-
"".join(result.response_output)
231+
"".join(result.response_output["output"])
228232
== f"Concurrent streaming request number {idx}"
229233
)
230234
assert result.error is None
@@ -265,7 +269,7 @@ async def track_resolution(future):
265269
assert resolution_count == 1
266270
assert resolved_result is not None
267271
assert resolved_result.id == "test-single-resolution"
268-
assert resolved_result.response_output == (
272+
assert resolved_result.response_output["output"] == (
269273
"Test",
270274
" single future resolution with multiple words",
271275
)
@@ -303,8 +307,10 @@ async def test_streaming_future_first_chunk_access(self, futures_http_client):
303307

304308
# Get complete response
305309
result = await future
306-
assert result.response_output[0] == "Test"
307-
assert result.response_output[1] == " first chunk access functionality"
310+
assert result.response_output["output"][0] == "Test"
311+
assert (
312+
result.response_output["output"][1] == " first chunk access functionality"
313+
)
308314

309315
# Test 2: Check if first chunk is ready after awaiting
310316
query2 = Query(
@@ -347,8 +353,7 @@ async def test_streaming_single_chunk_complete(self, futures_http_client):
347353

348354
# Complete response should be the same
349355
result = await future
350-
assert result.response_output[0] == "Hi"
351-
assert result.response_output[1] == ""
356+
assert result.response_output["output"] == ("Hi",)
352357

353358
@pytest.mark.asyncio
354359
async def test_streaming_race_first_chunks(self, futures_http_client):
@@ -391,8 +396,8 @@ async def test_streaming_race_first_chunks(self, futures_http_client):
391396
# Get first complete
392397
winner = done.pop().result()
393398
assert winner.id.startswith("race-")
394-
assert winner.response_output[0] == "Query"
395-
assert winner.response_output[1].startswith(" number")
399+
assert winner.response_output["output"][0] == "Query"
400+
assert winner.response_output["output"][1].startswith(" number")
396401

397402
# Clean up remaining
398403
for f in pending:
@@ -498,4 +503,4 @@ async def test_streaming_concurrent_mixed_lengths(self, futures_http_client):
498503
assert first == prompt.split()[0] if prompt else ""
499504

500505
result = await future
501-
assert "".join(result.response_output) == prompt
506+
assert "".join(result.response_output["output"]) == prompt

tests/integration/endpoint_client/test_worker_core.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ async def test_worker_streaming_request(
210210
assert responses[0].id == "test-streaming"
211211

212212
# Verify final response
213-
assert final_content == ("Stream", " this response please")
213+
assert final_content == {"output": ("Stream", " this response please")}
214214

215215
# Shutdown
216216
worker._shutdown = True
@@ -435,7 +435,9 @@ async def test_worker_streaming_first_last_token_metadata(
435435
# Verify final result metadata
436436
assert final_result.metadata.get("final_chunk") is True
437437
assert final_result.id == "test-first-last-token"
438-
assert final_result.response_output == ("Hello", " world this is a test")
438+
assert final_result.response_output == {
439+
"output": ("Hello", " world this is a test")
440+
}
439441

440442
# Verify intermediate chunks (if any) don't have first_chunk set to True
441443
for chunk in stream_chunks[1:]:
@@ -520,7 +522,7 @@ async def test_worker_streaming_empty_chunks(
520522
final_response = responses[-1]
521523
assert final_response.metadata.get("final_chunk") is True
522524
assert final_response.id == "test-empty-chunks"
523-
assert final_response.response_output == ("",) # Empty content
525+
assert final_response.response_output["output"] == () # Empty content
524526

525527
# Shutdown
526528
worker._shutdown = True
@@ -884,7 +886,7 @@ async def test_worker_streaming_chunk_before_final_single_word(
884886
assert not isinstance(
885887
last_response, StreamChunk
886888
), "Last response should not be a StreamChunk"
887-
assert last_response.response_output == ("Hi", "")
889+
assert last_response.response_output == {"output": ("Hi",)}
888890
assert last_response.metadata.get("final_chunk") is True
889891
assert last_response.id == "test-single-word-order"
890892

@@ -947,7 +949,7 @@ async def test_worker_streaming_chunk_before_final_single_word(
947949
assert not isinstance(
948950
last_empty, StreamChunk
949951
), "Last response should not be a StreamChunk"
950-
assert last_empty.response_output == ("",)
952+
assert last_empty.response_output == {"output": ()}
951953
assert last_empty.id == "test-empty-order"
952954

953955
# Shutdown

tests/integration/endpoint_client/test_worker_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ async def malformed_json_handler(request):
693693

694694
# Malformed JSON is skipped, so we get an empty response, not an error
695695
assert response.error is None
696-
assert response.response_output == ()
696+
assert response.response_output == {"output": ()}
697697

698698
# Shutdown
699699
worker._shutdown = True

0 commit comments

Comments
 (0)