|
23 | 23 |
|
24 | 24 | from runloop_api_client import Runloop, AsyncRunloop, APIResponseValidationError |
25 | 25 | from runloop_api_client._types import Omit |
26 | | -from runloop_api_client._utils import maybe_transform |
27 | 26 | from runloop_api_client._models import BaseModel, FinalRequestOptions |
28 | | -from runloop_api_client._constants import RAW_RESPONSE_HEADER |
29 | 27 | from runloop_api_client._exceptions import RunloopError, APIStatusError, APITimeoutError, APIResponseValidationError |
30 | 28 | from runloop_api_client._base_client import ( |
31 | 29 | DEFAULT_TIMEOUT, |
|
35 | 33 | DefaultAsyncHttpxClient, |
36 | 34 | make_request_options, |
37 | 35 | ) |
38 | | -from runloop_api_client.types.devbox_create_params import DevboxCreateParams |
39 | 36 |
|
40 | 37 | from .utils import update_env |
41 | 38 |
|
@@ -770,32 +767,21 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str |
770 | 767 |
|
771 | 768 | @mock.patch("runloop_api_client._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) |
772 | 769 | @pytest.mark.respx(base_url=base_url) |
773 | | - def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: |
| 770 | + def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Runloop) -> None: |
774 | 771 | respx_mock.post("/v1/devboxes").mock(side_effect=httpx.TimeoutException("Test timeout error")) |
775 | 772 |
|
776 | 773 | with pytest.raises(APITimeoutError): |
777 | | - self.client.post( |
778 | | - "/v1/devboxes", |
779 | | - body=cast(object, maybe_transform({}, DevboxCreateParams)), |
780 | | - cast_to=httpx.Response, |
781 | | - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, |
782 | | - ) |
| 774 | + client.devboxes.with_streaming_response.create().__enter__() |
783 | 775 |
|
784 | 776 | assert _get_open_connections(self.client) == 0 |
785 | 777 |
|
786 | 778 | @mock.patch("runloop_api_client._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) |
787 | 779 | @pytest.mark.respx(base_url=base_url) |
788 | | - def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: |
| 780 | + def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Runloop) -> None: |
789 | 781 | respx_mock.post("/v1/devboxes").mock(return_value=httpx.Response(500)) |
790 | 782 |
|
791 | 783 | with pytest.raises(APIStatusError): |
792 | | - self.client.post( |
793 | | - "/v1/devboxes", |
794 | | - body=cast(object, maybe_transform({}, DevboxCreateParams)), |
795 | | - cast_to=httpx.Response, |
796 | | - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, |
797 | | - ) |
798 | | - |
| 784 | + client.devboxes.with_streaming_response.create().__enter__() |
799 | 785 | assert _get_open_connections(self.client) == 0 |
800 | 786 |
|
801 | 787 | @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) |
@@ -1640,32 +1626,23 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte |
1640 | 1626 |
|
1641 | 1627 | @mock.patch("runloop_api_client._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) |
1642 | 1628 | @pytest.mark.respx(base_url=base_url) |
1643 | | - async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: |
| 1629 | + async def test_retrying_timeout_errors_doesnt_leak( |
| 1630 | + self, respx_mock: MockRouter, async_client: AsyncRunloop |
| 1631 | + ) -> None: |
1644 | 1632 | respx_mock.post("/v1/devboxes").mock(side_effect=httpx.TimeoutException("Test timeout error")) |
1645 | 1633 |
|
1646 | 1634 | with pytest.raises(APITimeoutError): |
1647 | | - await self.client.post( |
1648 | | - "/v1/devboxes", |
1649 | | - body=cast(object, maybe_transform({}, DevboxCreateParams)), |
1650 | | - cast_to=httpx.Response, |
1651 | | - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, |
1652 | | - ) |
| 1635 | + await async_client.devboxes.with_streaming_response.create().__aenter__() |
1653 | 1636 |
|
1654 | 1637 | assert _get_open_connections(self.client) == 0 |
1655 | 1638 |
|
1656 | 1639 | @mock.patch("runloop_api_client._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) |
1657 | 1640 | @pytest.mark.respx(base_url=base_url) |
1658 | | - async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: |
| 1641 | + async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncRunloop) -> None: |
1659 | 1642 | respx_mock.post("/v1/devboxes").mock(return_value=httpx.Response(500)) |
1660 | 1643 |
|
1661 | 1644 | with pytest.raises(APIStatusError): |
1662 | | - await self.client.post( |
1663 | | - "/v1/devboxes", |
1664 | | - body=cast(object, maybe_transform({}, DevboxCreateParams)), |
1665 | | - cast_to=httpx.Response, |
1666 | | - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, |
1667 | | - ) |
1668 | | - |
| 1645 | + await async_client.devboxes.with_streaming_response.create().__aenter__() |
1669 | 1646 | assert _get_open_connections(self.client) == 0 |
1670 | 1647 |
|
1671 | 1648 | @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) |
|
0 commit comments