Skip to content

controller_test

Automated controller testing.

ControllerTest

ControllerTest(
    client,
    base_path,
    collection,
    raw_collection,
    service_type,
    monkeypatch,
    collection_filters=None,
)

Standard controller testing utility.

Parameters:

Name Type Description Default
client TestClient

Test client instance.

required
base_path str

Path for POST and collection GET requests.

required
collection Sequence[orm.Base]

Collection of domain objects.

required
raw_collection Sequence[dict[str, Any]]

Collection of raw representations of domain objects.

required
service_type type[Service]

The domain Service object type.

required
monkeypatch MonkeyPatch

Pytest's monkeypatch.

required
collection_filters dict[str, Any] | None

Collection filters for GET collection request.

None

run

run()

Run the tests.

test_get_collection

test_get_collection(with_filters=False)

Test collection endpoint get request.

test_member_request

test_member_request(method, service_method, exp_status)

Test member endpoint request.