generated from coulomb/repo-seed
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>
61 lines
2.5 KiB
Python
61 lines
2.5 KiB
Python
"""Tests for DOCX→Markdown importer (FR-300, FR-400)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from markidocx.builder import build_document
|
|
from markidocx.importer import import_document
|
|
from markidocx.manifest import load_manifest
|
|
|
|
|
|
class TestImportDocument:
|
|
def test_import_missing_docx_fails(self, tmp_project: Path) -> None:
|
|
manifest = load_manifest(tmp_project / "manifest.yaml")
|
|
result = import_document(manifest, tmp_project / "missing.docx")
|
|
assert not result.success
|
|
assert result.mapping_status == "failed"
|
|
|
|
def test_import_roundtrip_single_source(self, tmp_project: Path) -> None:
|
|
manifest = load_manifest(tmp_project / "manifest.yaml")
|
|
build_result = build_document(manifest)
|
|
assert build_result.success
|
|
|
|
result = import_document(manifest, build_result.output_path)
|
|
assert result.success
|
|
assert len(result.output_files) == 1
|
|
assert result.mapping_status == "redistributed"
|
|
assert result.output_files[0].exists()
|
|
|
|
def test_imported_markdown_has_headings(self, tmp_project: Path) -> None:
|
|
manifest = load_manifest(tmp_project / "manifest.yaml")
|
|
build_result = build_document(manifest)
|
|
import_result = import_document(manifest, build_result.output_path)
|
|
assert import_result.success
|
|
md = import_result.output_files[0].read_text(encoding="utf-8")
|
|
assert "# " in md # at least one heading
|
|
|
|
def test_import_multi_source_merged_fallback(self, tmp_path: Path) -> None:
|
|
import yaml
|
|
|
|
for name in ("ch1.md", "ch2.md", "ch3.md"):
|
|
(tmp_path / name).write_text(f"# {name}\n\nContent of {name}.", encoding="utf-8")
|
|
(tmp_path / "manifest.yaml").write_text(
|
|
yaml.dump(
|
|
{
|
|
"project": {"name": "MultiBook", "feature_level": "level1", "family": "book"},
|
|
"sources": [{"path": "ch1.md"}, {"path": "ch2.md"}, {"path": "ch3.md"}],
|
|
"output": {"dir": "./dist"},
|
|
}
|
|
)
|
|
)
|
|
(tmp_path / "dist").mkdir()
|
|
manifest = load_manifest(tmp_path / "manifest.yaml")
|
|
build_result = build_document(manifest)
|
|
assert build_result.success
|
|
|
|
import_result = import_document(manifest, build_result.output_path)
|
|
assert import_result.success
|
|
# Should redistribute or merge — either way produces output
|
|
assert len(import_result.output_files) >= 1
|