|
| 1 | +import pytest |
| 2 | +from pathlib import Path |
| 3 | +import json |
| 4 | +import os |
| 5 | +import sys |
| 6 | + |
| 7 | +# Add tools to path |
| 8 | +sys.path.append(str(Path(__file__).parent.parent / 'tools' / 'continuity_legacy')) |
| 9 | + |
| 10 | +from doc_parity_check import run_parity_check |
| 11 | + |
| 12 | +def test_parity_check_functional(tmp_path): |
| 13 | + # Setup a mock project root |
| 14 | + repo_root = tmp_path |
| 15 | + cont_dir = repo_root / '.continuity' |
| 16 | + cont_dir.mkdir() |
| 17 | + |
| 18 | + # Create required files |
| 19 | + (cont_dir / 'DECISIONS_LOG.md').write_text("# Decisions", encoding='utf-8') |
| 20 | + (cont_dir / 'CONTEXT_CONTINUITY.md').write_text("# Context", encoding='utf-8') |
| 21 | + (cont_dir / 'TIMELINE.md').write_text("# Timeline", encoding='utf-8') |
| 22 | + (repo_root / 'README.md').write_text("# README", encoding='utf-8') |
| 23 | + (repo_root / 'STATE.json').write_text(json.dumps({"phase": "test"}), encoding='utf-8') |
| 24 | + (repo_root / 'continuity_legacy.json').write_text(json.dumps({ |
| 25 | + "project_name": "Test", |
| 26 | + "tool_version": "5.0.0" |
| 27 | + }), encoding='utf-8') |
| 28 | + |
| 29 | + # Run check |
| 30 | + report = run_parity_check(None, str(repo_root)) |
| 31 | + |
| 32 | + # Assert |
| 33 | + assert report['status'] == 'ok' |
| 34 | + assert 'Diferencia de paridad (checksum)' not in str(report) |
| 35 | + |
| 36 | +def test_parity_fails_on_missing_file(tmp_path): |
| 37 | + repo_root = tmp_path |
| 38 | + (repo_root / '.continuity').mkdir() |
| 39 | + (repo_root / 'README.md').write_text("# README", encoding='utf-8') |
| 40 | + |
| 41 | + report = run_parity_check(None, str(repo_root)) |
| 42 | + assert report['status'] != 'ok' |
| 43 | + assert 'attention_required' in report['status'] |
| 44 | + |
0 commit comments