Skip to content

Commit

Permalink
chore(tests): improve raw response test
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Sep 27, 2023
1 parent 4bbbb34 commit c1b79b6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ def _get_params(client: BaseClient) -> dict[str, str]:
class TestFinch:
client = Finch(base_url=base_url, access_token=access_token, _strict_response_validation=True)

def test_raw_response(self) -> None:
response = self.client.get("/providers", cast_to=httpx.Response)
@pytest.mark.respx(base_url=base_url)
def test_raw_response(self, respx_mock: MockRouter) -> None:
respx_mock.post("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))

response = self.client.post("/foo", cast_to=httpx.Response)
assert response.status_code == 200
assert isinstance(response, httpx.Response)
assert response.json() == {"foo": "bar"}

def test_copy(self) -> None:
copied = self.client.copy()
Expand Down Expand Up @@ -420,10 +424,15 @@ class Model(BaseModel):
class TestAsyncFinch:
client = AsyncFinch(base_url=base_url, access_token=access_token, _strict_response_validation=True)

async def test_raw_response(self) -> None:
response = await self.client.get("/providers", cast_to=httpx.Response)
@pytest.mark.respx(base_url=base_url)
@pytest.mark.asyncio
async def test_raw_response(self, respx_mock: MockRouter) -> None:
respx_mock.post("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))

response = await self.client.post("/foo", cast_to=httpx.Response)
assert response.status_code == 200
assert isinstance(response, httpx.Response)
assert response.json() == {"foo": "bar"}

def test_copy(self) -> None:
copied = self.client.copy()
Expand Down

0 comments on commit c1b79b6

Please sign in to comment.