|
27 | 27 | from gitpod._models import BaseModel, FinalRequestOptions
|
28 | 28 | from gitpod._constants import RAW_RESPONSE_HEADER
|
29 | 29 | from gitpod._exceptions import GitpodError, APIStatusError, APITimeoutError, APIResponseValidationError
|
30 |
| -from gitpod._base_client import DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, make_request_options |
| 30 | +from gitpod._base_client import ( |
| 31 | + DEFAULT_TIMEOUT, |
| 32 | + HTTPX_DEFAULT_TIMEOUT, |
| 33 | + BaseClient, |
| 34 | + DefaultHttpxClient, |
| 35 | + DefaultAsyncHttpxClient, |
| 36 | + make_request_options, |
| 37 | +) |
31 | 38 | from gitpod.types.identity_get_authenticated_identity_params import IdentityGetAuthenticatedIdentityParams
|
32 | 39 |
|
33 | 40 | from .utils import update_env
|
@@ -847,6 +854,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
|
847 | 854 |
|
848 | 855 | assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
849 | 856 |
|
| 857 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 858 | + # Test that the proxy environment variables are set correctly |
| 859 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 860 | + |
| 861 | + client = DefaultHttpxClient() |
| 862 | + |
| 863 | + mounts = tuple(client._mounts.items()) |
| 864 | + assert len(mounts) == 1 |
| 865 | + assert mounts[0][0].pattern == "https://" |
| 866 | + |
| 867 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 868 | + def test_default_client_creation(self) -> None: |
| 869 | + # Ensure that the client can be initialized without any exceptions |
| 870 | + DefaultHttpxClient( |
| 871 | + verify=True, |
| 872 | + cert=None, |
| 873 | + trust_env=True, |
| 874 | + http1=True, |
| 875 | + http2=False, |
| 876 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 877 | + ) |
| 878 | + |
850 | 879 | @pytest.mark.respx(base_url=base_url)
|
851 | 880 | def test_follow_redirects(self, respx_mock: MockRouter) -> None:
|
852 | 881 | # Test that the default follow_redirects=True allows following redirects
|
@@ -1722,6 +1751,28 @@ async def test_main() -> None:
|
1722 | 1751 |
|
1723 | 1752 | time.sleep(0.1)
|
1724 | 1753 |
|
| 1754 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1755 | + # Test that the proxy environment variables are set correctly |
| 1756 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1757 | + |
| 1758 | + client = DefaultAsyncHttpxClient() |
| 1759 | + |
| 1760 | + mounts = tuple(client._mounts.items()) |
| 1761 | + assert len(mounts) == 1 |
| 1762 | + assert mounts[0][0].pattern == "https://" |
| 1763 | + |
| 1764 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1765 | + async def test_default_client_creation(self) -> None: |
| 1766 | + # Ensure that the client can be initialized without any exceptions |
| 1767 | + DefaultAsyncHttpxClient( |
| 1768 | + verify=True, |
| 1769 | + cert=None, |
| 1770 | + trust_env=True, |
| 1771 | + http1=True, |
| 1772 | + http2=False, |
| 1773 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1774 | + ) |
| 1775 | + |
1725 | 1776 | @pytest.mark.respx(base_url=base_url)
|
1726 | 1777 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None:
|
1727 | 1778 | # Test that the default follow_redirects=True allows following redirects
|
|
0 commit comments