Files
DECNET/tests/topology/test_repository_protocol.py
anti fc1f0914b7 refactor(topology): introduce TopologyRepository protocol with DTO return types
Replace repo: BaseRepository with a structural TopologyRepository protocol
in persistence.py and allocator.py. All read methods now return typed DTOs
(TopologySummary, LANRow, DeckyRow, EdgeRow) instead of raw dicts, eliminating
silent field-shape regressions across the topology subsystem.

TopologySummary gains email_personas and language_default so api_personas.py
can continue reading those fields via attribute access. hydrate() converts
DTOs to dicts before passing to _backfill_decky_configs, keeping the mutable
working-state function dict-based at its boundary. All production callers
(router handlers, mutator, CLI, heartbeat) migrated from dict/get access to
attribute access. 134 tests pass.
2026-04-30 23:51:41 -04:00

22 lines
574 B
Python

"""Verify BaseRepository structurally satisfies TopologyRepository."""
_PROTOCOL_METHODS = {
"create_topology",
"get_topology",
"update_topology_status",
"list_topologies",
"add_lan",
"list_lans_for_topology",
"add_topology_decky",
"list_topology_deckies",
"add_topology_edge",
"list_topology_edges",
}
def test_base_repository_satisfies_protocol() -> None:
from decnet.web.db.repository import BaseRepository
for name in _PROTOCOL_METHODS:
assert hasattr(BaseRepository, name), f"BaseRepository missing {name!r}"