diff --git a/pyproject.toml b/pyproject.toml index 04d4971..139f69c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ dependencies = [ "pydantic-settings>=2", "modern-di-typer>=3,<4", "httpx2>=2", - "httpware[pydantic]>=0.15.0", + "httpware[pydantic]>=0.18.0", ] [project.scripts] diff --git a/tests/conftest.py b/tests/conftest.py index 589a182..e9c4bd4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -105,9 +105,9 @@ def gitlab_transport() -> httpx2.MockTransport: @pytest.fixture -def gitlab_client(gitlab_transport: httpx2.MockTransport) -> collections.abc.Iterator[httpx2.Client]: +def gitlab_http(gitlab_transport: httpx2.MockTransport) -> collections.abc.Iterator[httpware.Client]: config: typing.Final = GitLabConfig(endpoint=GITLAB_ENDPOINT, token=pydantic.SecretStr(GITLAB_TOKEN)) - with httpx2.Client( + with httpware.Client( transport=gitlab_transport, base_url=GITLAB_ENDPOINT, timeout=_REQUEST_TIMEOUT, @@ -116,11 +116,6 @@ def gitlab_client(gitlab_transport: httpx2.MockTransport) -> collections.abc.Ite yield client -@pytest.fixture -def gitlab_http(gitlab_client: httpx2.Client) -> httpware.Client: - return httpware.Client(httpx2_client=gitlab_client) - - @pytest.fixture def gitlab_provider(gitlab_http: httpware.Client) -> GitLabProvider: config: typing.Final = GitLabConfig(endpoint=GITLAB_ENDPOINT, token=pydantic.SecretStr(GITLAB_TOKEN)) diff --git a/tests/integration/README.md b/tests/integration/README.md index f1c1d3c..964386c 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -7,7 +7,7 @@ Integration tests inject `httpx2.MockTransport` into the production `httpware.Cl Two seams exist, depending on the test entry point: - **CLI-level tests** (`test_cli_*.py`) drive `semvertag.__main__` through Typer's `CliRunner` and let the DI container build the production stack. They override `ioc.ProvidersGroup.gitlab_client` with a mock-backed `httpware.Client` via the `install_mock_transport` fixture in `conftest.py`. -- **Provider-level tests** (`test_gitlab_provider.py`) bypass the container and call the `_make_provider(handler)` helper, which constructs an `httpware.Client(httpx2_client=httpx2.Client(transport=httpx2.MockTransport(handler), base_url=...))` directly. +- **Provider-level tests** (`test_gitlab_provider.py`) bypass the container and call the `_make_provider(handler)` helper, which constructs an `httpware.Client(transport=httpx2.MockTransport(handler), base_url=...)` directly. ## Disabling retry sleeps diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 8a317da..d7ef2ca 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -55,12 +55,7 @@ def cli_env(monkeypatch: pytest.MonkeyPatch) -> None: def install_mock_transport() -> typing.Iterator[collections.abc.Callable[[HandlerCallable], None]]: def install(handler: HandlerCallable) -> None: mock_transport: typing.Final = httpx2.MockTransport(handler) - mock_client: typing.Final = httpware.Client( - httpx2_client=httpx2.Client( - transport=mock_transport, - base_url=GITLAB_ENDPOINT, - ) - ) + mock_client: typing.Final = httpware.Client(transport=mock_transport, base_url=GITLAB_ENDPOINT) ioc.container.override(ioc.ProvidersGroup.gitlab_client, mock_client) with ioc.container: diff --git a/tests/integration/test_github_provider.py b/tests/integration/test_github_provider.py index 3ce9d59..1f2509d 100644 --- a/tests/integration/test_github_provider.py +++ b/tests/integration/test_github_provider.py @@ -60,11 +60,10 @@ def _make_provider( handler: HandlerCallable, *, default_branch: str | None = None, -) -> tuple[GitHubProvider, httpx2.Client]: - transport = httpx2.MockTransport(handler) +) -> tuple[GitHubProvider, httpware.Client]: config = GitHubConfig(endpoint=GITHUB_ENDPOINT, token=pydantic.SecretStr(GITHUB_TOKEN)) - inner = httpx2.Client( - transport=transport, + client = httpware.Client( + transport=httpx2.MockTransport(handler), base_url=GITHUB_ENDPOINT, headers={ "Authorization": f"Bearer {config.token.get_secret_value()}", @@ -72,11 +71,8 @@ def _make_provider( "X-GitHub-Api-Version": "2022-11-28", }, ) - client = httpware.Client(httpx2_client=inner) provider = GitHubProvider(config=config, repo=GITHUB_REPO, http=client, default_branch=default_branch) - # Return the inner httpx2.Client so tests can use it as a context manager - # for teardown; httpware.Client doesn't own its lifecycle when constructed via httpx2_client=. - return provider, inner + return provider, client # Protocol conformance diff --git a/tests/integration/test_gitlab_provider.py b/tests/integration/test_gitlab_provider.py index 3df0f3f..d078500 100644 --- a/tests/integration/test_gitlab_provider.py +++ b/tests/integration/test_gitlab_provider.py @@ -44,21 +44,17 @@ def _make_provider( handler: HandlerCallable, *, default_branch: str | None = None, -) -> tuple[GitLabProvider, httpx2.Client]: - transport: typing.Final = httpx2.MockTransport(handler) +) -> tuple[GitLabProvider, httpware.Client]: config: typing.Final = GitLabConfig(endpoint=GITLAB_ENDPOINT, token=pydantic.SecretStr(GITLAB_TOKEN)) - inner_client: typing.Final = httpx2.Client( - transport=transport, + http: typing.Final = httpware.Client( + transport=httpx2.MockTransport(handler), base_url=GITLAB_ENDPOINT, headers={_TOKEN_HEADER: config.token.get_secret_value()}, ) - http: typing.Final = httpware.Client(httpx2_client=inner_client) provider: typing.Final = GitLabProvider( config=config, project_id=GITLAB_PROJECT_ID, http=http, default_branch=default_branch ) - # Return the inner httpx2.Client so tests can use it as a context manager - # for teardown; httpware.Client doesn't own its lifecycle when constructed via httpx2_client=. - return provider, inner_client + return provider, http # Protocol conformance