HTTP¶
The HTTP response assertable, the request/message builders, and the framework adapters. See the HTTP guide for examples.
Response¶
pyssertive.http.FluentResponse ¶
Bases: DebugResponseMixin, CookieAssertionsMixin, HTMLContentAssertionsMixin, JsonContentAssertionsMixin, HeaderAssertionsMixin, HttpStatusAssertionsMixin
Framework-agnostic fluent assertion wrapper for HTTP responses.
Concrete adapter subclasses (e.g. pyssertive.adapters.django.FluentResponse
or pyssertive.adapters.httpx.FluentResponse) define their own
__init__ with the framework-native response type and override
properties when the underlying response shape diverges (e.g. httpx
exposes charset_encoding instead of charset).
Every concrete FluentResponse satisfies :class:ResponseProtocol,
so developers can write helpers typed against that protocol and have
them work uniformly across adapters.
Message builder¶
pyssertive.http.mcp.MessageBuilder ¶
MessageBuilder(
request_builder: RequestBuilder[TBuilt],
*,
path: str = DEFAULT_PATH,
)
Bases: Generic[TBuilt]
Source code in src/pyssertive/http/mcp.py
with_id ¶
with_auth_token ¶
with_protocol_version ¶
with_session_id ¶
initialize ¶
initialize(
*,
protocol: str = "2025-11-25",
client_name: str = "pyssertive-test",
client_version: str = "0.0.0",
capabilities: dict[str, Any] | None = None,
) -> Self
Source code in src/pyssertive/http/mcp.py
listing_tools ¶
calling_tool ¶
listing_resources ¶
reading_resource ¶
listing_prompts ¶
getting_prompt ¶
Source code in src/pyssertive/http/mcp.py
notifying ¶
calling ¶
with_params ¶
build ¶
Source code in src/pyssertive/http/mcp.py
Django adapter¶
pyssertive.adapters.django.FluentHttpAssertClient ¶
pyssertive.adapters.django.DjangoRequestBuilder ¶
DjangoRequestBuilder(
rf: RequestFactory | None = None,
method: str = "GET",
base_url: str | None = None,
path: str = "/",
data: dict[str, Any] | None = None,
)
Bases: BaseRequestBuilder[HttpRequest]
Source code in src/pyssertive/adapters/django/request.py
with_user ¶
with_meta ¶
with_property ¶
build ¶
Source code in src/pyssertive/adapters/django/request.py
Database helpers¶
pyssertive.adapters.django.db ¶
assert_queryset_equal ¶
assert_queryset_equal(
actual: QuerySet | list[Any] | Iterator[Any],
expected: Collection,
*,
transform: Callable[[Any], Any] = repr,
ordered: bool = True,
) -> None
Source code in src/pyssertive/adapters/django/db.py
assert_num_queries ¶
Source code in src/pyssertive/adapters/django/db.py
assert_model_exists ¶
assert_model_not_exists ¶
assert_model_count ¶
Source code in src/pyssertive/adapters/django/db.py
assert_model_soft_deleted ¶
Assumes model uses soft-deletion with a deleted_at datetime field.
Source code in src/pyssertive/adapters/django/db.py
httpx adapter¶
pyssertive.adapters.httpx.FluentHttpAssertClient ¶
pyssertive.adapters.httpx.HttpxRequestBuilder ¶
HttpxRequestBuilder(
method: str = "GET",
base_url: str | None = None,
path: str = "/",
data: dict[str, Any] | None = None,
)
Bases: BaseRequestBuilder[Request]