MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / test_basic_union_response

Method test_basic_union_response

tests/test_client.py:458–469  ·  view source on GitHub ↗
(self, respx_mock: MockRouter)

Source from the content-addressed store, hash-verified

456
457 @pytest.mark.respx(base_url=base_url)
458 def test_basic_union_response(self, respx_mock: MockRouter) -> None:
459 class Model1(BaseModel):
460 name: str
461
462 class Model2(BaseModel):
463 foo: str
464
465 respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
466
467 response = self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2]))
468 assert isinstance(response, Model2)
469 assert response.foo == "bar"
470
471 @pytest.mark.respx(base_url=base_url)
472 def test_union_response_different_types(self, respx_mock: MockRouter) -> None:

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected