|
27 | 27 | from lithic._models import BaseModel, FinalRequestOptions |
28 | 28 | from lithic._constants import RAW_RESPONSE_HEADER |
29 | 29 | from lithic._exceptions import LithicError, APIStatusError, APITimeoutError, APIResponseValidationError |
30 | | -from lithic._base_client import DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, make_request_options |
| 30 | +from lithic._base_client import ( |
| 31 | + DEFAULT_TIMEOUT, |
| 32 | + HTTPX_DEFAULT_TIMEOUT, |
| 33 | + BaseClient, |
| 34 | + DefaultHttpxClient, |
| 35 | + DefaultAsyncHttpxClient, |
| 36 | + make_request_options, |
| 37 | +) |
31 | 38 | from lithic.types.card_create_params import CardCreateParams |
32 | 39 |
|
33 | 40 | from .utils import update_env |
@@ -846,6 +853,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: |
846 | 853 | assert response.retries_taken == failures_before_success |
847 | 854 | assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success |
848 | 855 |
|
| 856 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 857 | + # Test that the proxy environment variables are set correctly |
| 858 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 859 | + |
| 860 | + client = DefaultHttpxClient() |
| 861 | + |
| 862 | + mounts = tuple(client._mounts.items()) |
| 863 | + assert len(mounts) == 1 |
| 864 | + assert mounts[0][0].pattern == "https://" |
| 865 | + |
| 866 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 867 | + def test_default_client_creation(self) -> None: |
| 868 | + # Ensure that the client can be initialized without any exceptions |
| 869 | + DefaultHttpxClient( |
| 870 | + verify=True, |
| 871 | + cert=None, |
| 872 | + trust_env=True, |
| 873 | + http1=True, |
| 874 | + http2=False, |
| 875 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 876 | + ) |
| 877 | + |
849 | 878 | @pytest.mark.respx(base_url=base_url) |
850 | 879 | def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
851 | 880 | # Test that the default follow_redirects=True allows following redirects |
@@ -1735,6 +1764,28 @@ async def test_main() -> None: |
1735 | 1764 |
|
1736 | 1765 | time.sleep(0.1) |
1737 | 1766 |
|
| 1767 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1768 | + # Test that the proxy environment variables are set correctly |
| 1769 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1770 | + |
| 1771 | + client = DefaultAsyncHttpxClient() |
| 1772 | + |
| 1773 | + mounts = tuple(client._mounts.items()) |
| 1774 | + assert len(mounts) == 1 |
| 1775 | + assert mounts[0][0].pattern == "https://" |
| 1776 | + |
| 1777 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1778 | + async def test_default_client_creation(self) -> None: |
| 1779 | + # Ensure that the client can be initialized without any exceptions |
| 1780 | + DefaultAsyncHttpxClient( |
| 1781 | + verify=True, |
| 1782 | + cert=None, |
| 1783 | + trust_env=True, |
| 1784 | + http1=True, |
| 1785 | + http2=False, |
| 1786 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1787 | + ) |
| 1788 | + |
1738 | 1789 | @pytest.mark.respx(base_url=base_url) |
1739 | 1790 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
1740 | 1791 | # Test that the default follow_redirects=True allows following redirects |
|
0 commit comments