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
|