testing

Reusable conformance helpers for otto’s pluggable backend interfaces. Call one per interface from a pytest test; each raises a single AssertionError listing every contract violation.

otto.testing.assert_lab_repository_conforms(repo: LabRepository, *, expected_labs: list[str] | None = None) None

Assert repo satisfies the LabRepository contract.

Runs structural rules unconditionally; for every listed lab, asserts it loads to a valid Lab; asserts an unknown name raises LabNotFoundError. When expected_labs is given, also asserts each appears in list_labs() and loads. Raises a single AssertionError aggregating every violated rule.

Parameters

repoLabRepository

The backend instance under test.

expected_labslist[str] | None

Optional lab names the caller knows the backend should provide.

otto.testing.assert_reservation_backend_conforms(backend: ReservationBackend, *, known_user: str | None = None, known_resources: list[str] | None = None) None

Assert backend satisfies the ReservationBackend contract.

Structural/type rules always run. When known_user and known_resources (resources that user is known to hold) are both given, round-trip consistency rules run too. The optional SupportsUsernameCompletion capability is checked only when the backend implements it. Raises a single AssertionError aggregating every violated rule.

Parameters

backendReservationBackend

The backend instance under test.

known_userstr | None

A username known to hold known_resources (enables round-trip rules).

known_resourceslist[str] | None

Resources known_user is known to currently hold.