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
LabRepositorycontract.Runs structural rules unconditionally; for every listed lab, asserts it loads to a valid
Lab; asserts an unknown name raisesLabNotFoundError. When expected_labs is given, also asserts each appears inlist_labs()and loads. Raises a singleAssertionErroraggregating 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
SupportsUsernameCompletioncapability is checked only when the backend implements it. Raises a singleAssertionErroraggregating 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_useris known to currently hold.