generated from coulomb/repo-seed
feat(coordination): Overlay model + OverlayEngine.draft (WP-0008 T2)
Overlay value type (id, target, base_rev, body, state) recorded as an OVERLAY_CREATED decision-log event (coordination-canonical); get()/open_overlays() reconstruct from the fold. 4 tests green, pyflakes clean. (ADR-05, blueprint §8.2) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
42
tests/test_overlay.py
Normal file
42
tests/test_overlay.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""Tests for the overlay model + draft (SHARD-WP-0008 T2)."""
|
||||
|
||||
from shard_wiki.coordination import DecisionLog, EventType, OverlayEngine
|
||||
from shard_wiki.model import Identity
|
||||
from shard_wiki.provenance import OverlayState
|
||||
|
||||
|
||||
def test_draft_records_event_and_is_retrievable():
|
||||
log = DecisionLog()
|
||||
eng = OverlayEngine("space", log)
|
||||
ov = eng.draft(Identity("shardA", "Home"), "new body", base_rev="r1")
|
||||
|
||||
assert ov.state is OverlayState.DRAFT
|
||||
assert ov.body == "new body"
|
||||
# recorded in the log (coordination-canonical)
|
||||
events = log.events("space")
|
||||
assert len(events) == 1 and events[0].type is EventType.OVERLAY_CREATED
|
||||
# retrievable through the fold by its id
|
||||
got = eng.get(ov.overlay_id)
|
||||
assert got is not None
|
||||
assert got.target == Identity("shardA", "Home")
|
||||
assert got.base_rev == "r1"
|
||||
assert got.body == "new body"
|
||||
|
||||
|
||||
def test_open_overlays_lists_drafts():
|
||||
log = DecisionLog()
|
||||
eng = OverlayEngine("space", log)
|
||||
eng.draft(Identity("s", "A"), "a", base_rev=None)
|
||||
eng.draft(Identity("s", "B"), "b", base_rev=None)
|
||||
assert {o.target.key for o in eng.open_overlays()} == {"A", "B"}
|
||||
|
||||
|
||||
def test_unknown_overlay_is_none():
|
||||
assert OverlayEngine("space", DecisionLog()).get("nope") is None
|
||||
|
||||
|
||||
def test_overlay_payload_round_trips():
|
||||
log = DecisionLog()
|
||||
eng = OverlayEngine("space", log)
|
||||
ov = eng.draft(Identity("shardA", "sub/Page"), "x", base_rev="r9")
|
||||
assert eng.get(ov.overlay_id) == ov # payload reconstructs an equal Overlay
|
||||
Reference in New Issue
Block a user