generated from coulomb/repo-seed
render_patch(overlay, base_body) → Patch (pure difflib unified diff, target- labelled); is_empty when unchanged. 3 tests green, pyflakes clean. (ADR-05) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
916 B
Python
30 lines
916 B
Python
"""Tests for patch rendering (SHARD-WP-0008 T3)."""
|
|
|
|
from shard_wiki.coordination import Overlay, Patch, render_patch
|
|
from shard_wiki.model import Identity
|
|
|
|
|
|
def _overlay(body: str) -> Overlay:
|
|
return Overlay("ov1", Identity("shardA", "Home"), base_rev="r1", body=body)
|
|
|
|
|
|
def test_patch_shows_the_change():
|
|
patch = render_patch(_overlay("line one\nline TWO\n"), "line one\nline two\n")
|
|
assert isinstance(patch, Patch)
|
|
assert not patch.is_empty
|
|
assert "-line two" in patch.diff
|
|
assert "+line TWO" in patch.diff
|
|
assert patch.target == Identity("shardA", "Home")
|
|
|
|
|
|
def test_empty_patch_when_unchanged():
|
|
patch = render_patch(_overlay("same\n"), "same\n")
|
|
assert patch.is_empty
|
|
assert patch.diff == ""
|
|
|
|
|
|
def test_patch_labels_name_the_target():
|
|
patch = render_patch(_overlay("new\n"), "old\n")
|
|
assert "a/shardA:Home" in patch.diff
|
|
assert "b/shardA:Home" in patch.diff
|