|
23 | 23 |
|
24 | 24 | from gitpod import Gitpod, AsyncGitpod, APIResponseValidationError |
25 | 25 | from gitpod._types import Omit |
26 | | -from gitpod._utils import maybe_transform |
27 | 26 | from gitpod._models import BaseModel, FinalRequestOptions |
28 | | -from gitpod._constants import RAW_RESPONSE_HEADER |
29 | 27 | from gitpod._exceptions import GitpodError, APIStatusError, APITimeoutError, APIResponseValidationError |
30 | 28 | from gitpod._base_client import ( |
31 | 29 | DEFAULT_TIMEOUT, |
|
35 | 33 | DefaultAsyncHttpxClient, |
36 | 34 | make_request_options, |
37 | 35 | ) |
38 | | -from gitpod.types.identity_get_authenticated_identity_params import IdentityGetAuthenticatedIdentityParams |
39 | 36 |
|
40 | 37 | from .utils import update_env |
41 | 38 |
|
@@ -743,34 +740,23 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str |
743 | 740 |
|
744 | 741 | @mock.patch("gitpod._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) |
745 | 742 | @pytest.mark.respx(base_url=base_url) |
746 | | - def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: |
| 743 | + def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Gitpod) -> None: |
747 | 744 | respx_mock.post("/gitpod.v1.IdentityService/GetAuthenticatedIdentity").mock( |
748 | 745 | side_effect=httpx.TimeoutException("Test timeout error") |
749 | 746 | ) |
750 | 747 |
|
751 | 748 | with pytest.raises(APITimeoutError): |
752 | | - self.client.post( |
753 | | - "/gitpod.v1.IdentityService/GetAuthenticatedIdentity", |
754 | | - body=cast(object, maybe_transform({}, IdentityGetAuthenticatedIdentityParams)), |
755 | | - cast_to=httpx.Response, |
756 | | - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, |
757 | | - ) |
| 749 | + client.identity.with_streaming_response.get_authenticated_identity().__enter__() |
758 | 750 |
|
759 | 751 | assert _get_open_connections(self.client) == 0 |
760 | 752 |
|
761 | 753 | @mock.patch("gitpod._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) |
762 | 754 | @pytest.mark.respx(base_url=base_url) |
763 | | - def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: |
| 755 | + def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Gitpod) -> None: |
764 | 756 | respx_mock.post("/gitpod.v1.IdentityService/GetAuthenticatedIdentity").mock(return_value=httpx.Response(500)) |
765 | 757 |
|
766 | 758 | with pytest.raises(APIStatusError): |
767 | | - self.client.post( |
768 | | - "/gitpod.v1.IdentityService/GetAuthenticatedIdentity", |
769 | | - body=cast(object, maybe_transform({}, IdentityGetAuthenticatedIdentityParams)), |
770 | | - cast_to=httpx.Response, |
771 | | - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, |
772 | | - ) |
773 | | - |
| 759 | + client.identity.with_streaming_response.get_authenticated_identity().__enter__() |
774 | 760 | assert _get_open_connections(self.client) == 0 |
775 | 761 |
|
776 | 762 | @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) |
@@ -1592,34 +1578,23 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte |
1592 | 1578 |
|
1593 | 1579 | @mock.patch("gitpod._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) |
1594 | 1580 | @pytest.mark.respx(base_url=base_url) |
1595 | | - async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: |
| 1581 | + async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncGitpod) -> None: |
1596 | 1582 | respx_mock.post("/gitpod.v1.IdentityService/GetAuthenticatedIdentity").mock( |
1597 | 1583 | side_effect=httpx.TimeoutException("Test timeout error") |
1598 | 1584 | ) |
1599 | 1585 |
|
1600 | 1586 | with pytest.raises(APITimeoutError): |
1601 | | - await self.client.post( |
1602 | | - "/gitpod.v1.IdentityService/GetAuthenticatedIdentity", |
1603 | | - body=cast(object, maybe_transform({}, IdentityGetAuthenticatedIdentityParams)), |
1604 | | - cast_to=httpx.Response, |
1605 | | - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, |
1606 | | - ) |
| 1587 | + await async_client.identity.with_streaming_response.get_authenticated_identity().__aenter__() |
1607 | 1588 |
|
1608 | 1589 | assert _get_open_connections(self.client) == 0 |
1609 | 1590 |
|
1610 | 1591 | @mock.patch("gitpod._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) |
1611 | 1592 | @pytest.mark.respx(base_url=base_url) |
1612 | | - async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: |
| 1593 | + async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncGitpod) -> None: |
1613 | 1594 | respx_mock.post("/gitpod.v1.IdentityService/GetAuthenticatedIdentity").mock(return_value=httpx.Response(500)) |
1614 | 1595 |
|
1615 | 1596 | with pytest.raises(APIStatusError): |
1616 | | - await self.client.post( |
1617 | | - "/gitpod.v1.IdentityService/GetAuthenticatedIdentity", |
1618 | | - body=cast(object, maybe_transform({}, IdentityGetAuthenticatedIdentityParams)), |
1619 | | - cast_to=httpx.Response, |
1620 | | - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, |
1621 | | - ) |
1622 | | - |
| 1597 | + await async_client.identity.with_streaming_response.get_authenticated_identity().__aenter__() |
1623 | 1598 | assert _get_open_connections(self.client) == 0 |
1624 | 1599 |
|
1625 | 1600 | @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) |
|
0 commit comments