Files
wehub-resource-sync 9201ef759e
Harness Compat / harness compat (push) Failing after 0s
CI / test on 3.12 (standard) (push) Has been cancelled
CI / test on 3.13 (standard) (push) Has been cancelled
CI / test on 3.14 (standard) (push) Has been cancelled
CI / test on 3.10 (all-extras) (push) Has been cancelled
CI / test on 3.11 (all-extras) (push) Has been cancelled
CI / test on 3.12 (all-extras) (push) Has been cancelled
CI / test on 3.14 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.10 (pydantic-evals) (push) Has been cancelled
CI / test on 3.11 (pydantic-evals) (push) Has been cancelled
CI / test on 3.12 (pydantic-evals) (push) Has been cancelled
CI / deploy-docs-preview (push) Has been cancelled
CI / build release artifacts (push) Has been cancelled
CI / publish to PyPI (push) Has been cancelled
CI / Send tweet (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / mypy (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / test on 3.10 (standard) (push) Has been cancelled
CI / test on 3.11 (standard) (push) Has been cancelled
CI / test on 3.13 (all-extras) (push) Has been cancelled
CI / test on 3.14 (all-extras) (push) Has been cancelled
CI / test on 3.10 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.11 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.12 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.13 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.13 (pydantic-evals) (push) Has been cancelled
CI / test on 3.14 (pydantic-evals) (push) Has been cancelled
CI / test on 3.10 (lowest-versions) (push) Has been cancelled
CI / test on 3.11 (lowest-versions) (push) Has been cancelled
CI / test on 3.12 (lowest-versions) (push) Has been cancelled
CI / test on 3.13 (lowest-versions) (push) Has been cancelled
CI / test on 3.14 (lowest-versions) (push) Has been cancelled
CI / test examples on 3.11 (push) Has been cancelled
CI / test examples on 3.12 (push) Has been cancelled
CI / test examples on 3.13 (push) Has been cancelled
CI / test examples on 3.14 (push) Has been cancelled
CI / coverage (push) Has been cancelled
CI / check (push) Has been cancelled
CI / deploy-docs (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:27:52 +08:00

52 lines
2.3 KiB
Python

from __future__ import annotations as _annotations
import pytest
from ..conftest import TestEnv, try_import
with try_import() as imports_successful:
from google.genai.types import HttpRetryOptions
from pydantic_ai.providers.google import GoogleProvider
from pydantic_ai.providers.google_cloud import GoogleCloudProvider
pytestmark = pytest.mark.skipif(not imports_successful(), reason='google-genai not installed')
# `retry_options` only changes behavior on transient 429/5xx responses, which a recorded cassette
# can't reliably reproduce, so these unit tests assert the resolved HTTP config directly via the
# SDK's `get_read_only_http_options()` accessor rather than running an agent against a cassette.
def test_google_provider_retry_options(env: TestEnv):
env.set('GOOGLE_API_KEY', 'test-key')
retry = HttpRetryOptions(attempts=4, initial_delay=2.0, max_delay=30.0)
provider = GoogleProvider(api_key='test-key', retry_options=retry)
assert provider.name == 'google'
opts = provider.client._api_client.get_read_only_http_options() # pyright: ignore[reportPrivateUsage]
assert opts['retry_options']['attempts'] == 4
assert opts['retry_options']['initial_delay'] == 2.0
assert opts['retry_options']['max_delay'] == 30.0
def test_google_provider_no_retry_options(env: TestEnv):
env.set('GOOGLE_API_KEY', 'test-key')
provider = GoogleProvider(api_key='test-key')
opts = provider.client._api_client.get_read_only_http_options() # pyright: ignore[reportPrivateUsage]
assert opts['retry_options'] is None
def test_google_cloud_provider_retry_options():
retry = HttpRetryOptions(attempts=4, initial_delay=2.0, max_delay=30.0)
provider = GoogleCloudProvider(project='pydantic-ai', location='us-central1', retry_options=retry)
assert provider.name == 'google-cloud'
opts = provider.client._api_client.get_read_only_http_options() # pyright: ignore[reportPrivateUsage]
assert opts['retry_options']['attempts'] == 4
assert opts['retry_options']['initial_delay'] == 2.0
assert opts['retry_options']['max_delay'] == 30.0
def test_google_cloud_provider_no_retry_options():
provider = GoogleCloudProvider(project='pydantic-ai', location='us-central1')
opts = provider.client._api_client.get_read_only_http_options() # pyright: ignore[reportPrivateUsage]
assert opts['retry_options'] is None