Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 2 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 1 addition & 6 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 4 additions & 8 deletions tests/integration/test_github_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,19 @@ 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()}",
"Accept": "application/vnd.github+json",
"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
Expand Down
12 changes: 4 additions & 8 deletions tests/integration/test_gitlab_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading