Files
marki-docx/tests/test_differ.py
Bernd Worsch 1f3dddf7d6 feat: WP-0001 + WP-0002 complete — LEVEL1 core + service interfaces
WP-0001 (Foundation & LEVEL1 Core):
- manifest model (FR-100), MD→DOCX builder (FR-200), DOCX→MD importer
  (FR-300/400), template family registry (FR-600), drift detector (FR-700),
  CLI wiring, pre-commit config, CI skeleton, regression harness

WP-0002 (Service Interfaces & Workflow Orchestration):
- REST service via FastAPI (FR-900): /health, /version, /capabilities,
  /templates, /styles, /validate, /build, /import, /compare,
  /templates/register, /workflows/{name}, /evidence/{run_id}
- Evidence & report store (FR-1400): JSON-backed, per-run, retrievable
  through all interfaces, classification (pass/warnings/failed)
- Composite workflow orchestration (FR-1300): single-file-roundtrip,
  multi-file-roundtrip, release-regression, family-switch-build
- MCP server via FastMCP (FR-1000): all tools + resources
- CLI additions: `markidocx serve`, `markidocx workflow`, `markidocx mcp`
- Interface parity tests: CLI / REST / MCP produce equivalent results

135 tests passing, ruff + mypy clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 07:46:31 +00:00

45 lines
1.5 KiB
Python

"""Tests for structural drift detection (FR-700)."""
from __future__ import annotations
from markidocx.differ import compare
class TestCompare:
def test_identical_text_no_drift(self) -> None:
md = "# Heading\n\nParagraph.\n\n- item one\n- item two"
report = compare(md, md)
assert not report.has_drift
assert report.preserved
assert not report.broken
assert not report.degraded
def test_missing_heading_detected(self) -> None:
original = "# Heading One\n\n## Heading Two\n\nText."
reimported = "# Heading One\n\nText."
report = compare(original, reimported)
assert report.has_drift
assert any("Heading Two" in b for b in report.broken)
def test_missing_list_item_detected(self) -> None:
original = "- alpha\n- beta\n- gamma"
reimported = "- alpha\n- gamma"
report = compare(original, reimported)
assert report.has_drift
assert any("beta" in b for b in report.broken)
def test_preserved_links_tracked(self) -> None:
md = "See [example](https://example.com) for details."
report = compare(md, md)
assert any("link" in p for p in report.preserved)
def test_empty_strings_no_drift(self) -> None:
report = compare("", "")
assert not report.has_drift
def test_table_presence_checked(self) -> None:
original = "| A | B |\n|---|---|\n| 1 | 2 |"
reimported = "No table here."
report = compare(original, reimported)
assert report.has_drift