|
27 | 27 | from codex._models import BaseModel, FinalRequestOptions |
28 | 28 | from codex._constants import RAW_RESPONSE_HEADER |
29 | 29 | from codex._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError |
30 | | -from codex._base_client import DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, make_request_options |
| 30 | +from codex._base_client import ( |
| 31 | + DEFAULT_TIMEOUT, |
| 32 | + HTTPX_DEFAULT_TIMEOUT, |
| 33 | + BaseClient, |
| 34 | + DefaultHttpxClient, |
| 35 | + DefaultAsyncHttpxClient, |
| 36 | + make_request_options, |
| 37 | +) |
31 | 38 | from codex.types.project_create_params import ProjectCreateParams |
32 | 39 |
|
33 | 40 | from .utils import update_env |
@@ -803,6 +810,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: |
803 | 810 |
|
804 | 811 | assert response.http_request.headers.get("x-stainless-retry-count") == "42" |
805 | 812 |
|
| 813 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 814 | + # Test that the proxy environment variables are set correctly |
| 815 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 816 | + |
| 817 | + client = DefaultHttpxClient() |
| 818 | + |
| 819 | + mounts = tuple(client._mounts.items()) |
| 820 | + assert len(mounts) == 1 |
| 821 | + assert mounts[0][0].pattern == "https://" |
| 822 | + |
| 823 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 824 | + def test_default_client_creation(self) -> None: |
| 825 | + # Ensure that the client can be initialized without any exceptions |
| 826 | + DefaultHttpxClient( |
| 827 | + verify=True, |
| 828 | + cert=None, |
| 829 | + trust_env=True, |
| 830 | + http1=True, |
| 831 | + http2=False, |
| 832 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 833 | + ) |
| 834 | + |
806 | 835 | @pytest.mark.respx(base_url=base_url) |
807 | 836 | def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
808 | 837 | # Test that the default follow_redirects=True allows following redirects |
@@ -1637,6 +1666,28 @@ async def test_main() -> None: |
1637 | 1666 |
|
1638 | 1667 | time.sleep(0.1) |
1639 | 1668 |
|
| 1669 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1670 | + # Test that the proxy environment variables are set correctly |
| 1671 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1672 | + |
| 1673 | + client = DefaultAsyncHttpxClient() |
| 1674 | + |
| 1675 | + mounts = tuple(client._mounts.items()) |
| 1676 | + assert len(mounts) == 1 |
| 1677 | + assert mounts[0][0].pattern == "https://" |
| 1678 | + |
| 1679 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1680 | + async def test_default_client_creation(self) -> None: |
| 1681 | + # Ensure that the client can be initialized without any exceptions |
| 1682 | + DefaultAsyncHttpxClient( |
| 1683 | + verify=True, |
| 1684 | + cert=None, |
| 1685 | + trust_env=True, |
| 1686 | + http1=True, |
| 1687 | + http2=False, |
| 1688 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1689 | + ) |
| 1690 | + |
1640 | 1691 | @pytest.mark.respx(base_url=base_url) |
1641 | 1692 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
1642 | 1693 | # Test that the default follow_redirects=True allows following redirects |
|
0 commit comments