Skip to content

Commit a5c3b04

Browse files
committed
test(stubs): remove duplicate test, add scalar and priority coverage
1 parent d6959b5 commit a5c3b04

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

tests/unit/test_stub_live_serverless.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,32 @@ def test_handle_response_void_function_returns_none(self, stub):
185185
result = stub.handle_response(response)
186186
assert result is None
187187

188-
def test_handle_response_json_result(self, stub):
189-
"""handle_response returns json_result when result is None but json_result is set."""
188+
def test_handle_response_json_result_dict(self, stub):
189+
"""handle_response returns json_result dict when result is None."""
190190
response = FunctionResponse(
191191
success=True, result=None, json_result={"key": "value"}
192192
)
193193

194194
result = stub.handle_response(response)
195195
assert result == {"key": "value"}
196196

197-
def test_handle_response_json_result_none_value(self, stub):
198-
"""handle_response returns None when json_result is explicitly None (void json function)."""
199-
response = FunctionResponse(success=True, result=None, json_result=None)
197+
def test_handle_response_json_result_scalar(self, stub):
198+
"""handle_response returns json_result scalar without deserialization."""
199+
response = FunctionResponse(success=True, result=None, json_result=42)
200200

201201
result = stub.handle_response(response)
202-
assert result is None
202+
assert result == 42
203+
204+
def test_handle_response_result_takes_priority_over_json_result(self, stub):
205+
"""handle_response prefers cloudpickle result over json_result when both set."""
206+
result_data = "from_cloudpickle"
207+
encoded = base64.b64encode(cloudpickle.dumps(result_data)).decode()
208+
response = FunctionResponse(
209+
success=True, result=encoded, json_result="from_json"
210+
)
211+
212+
result = stub.handle_response(response)
213+
assert result == "from_cloudpickle"
203214

204215
def test_handle_response_prints_stdout(self, stub, capsys):
205216
"""handle_response prints stdout lines."""

0 commit comments

Comments
 (0)