generated from coulomb/repo-seed
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
from datetime import date
|
|
|
|
from repo_scoping.intent.bootstrap import bootstrap_intent_from_scope, scope_to_intent_text
|
|
|
|
|
|
def test_scope_to_intent_text_replaces_scope_heading_and_marks_bootstrap():
|
|
text = scope_to_intent_text(
|
|
"# SCOPE.md - Demo\n\n## One-liner\n\nCurrent utility.\n",
|
|
today=date(2026, 5, 2),
|
|
)
|
|
|
|
assert text.startswith("# INTENT\n\n")
|
|
assert "Bootstrapped from `SCOPE.md`" in text
|
|
assert "Bootstrap date: 2026-05-02" in text
|
|
assert "## One-liner\n\nCurrent utility." in text
|
|
|
|
|
|
def test_bootstrap_intent_from_scope_creates_intent_when_missing(tmp_path):
|
|
repo = tmp_path / "repo"
|
|
repo.mkdir()
|
|
(repo / "SCOPE.md").write_text("# SCOPE\n\nProvides search.\n", encoding="utf-8")
|
|
|
|
result = bootstrap_intent_from_scope(repo, today=date(2026, 5, 2))
|
|
|
|
assert result.status == "created"
|
|
intent_text = (repo / "INTENT.md").read_text(encoding="utf-8")
|
|
assert intent_text.startswith("# INTENT")
|
|
assert "Provides search." in intent_text
|
|
|
|
|
|
def test_bootstrap_intent_from_scope_does_not_overwrite_existing_intent(tmp_path):
|
|
repo = tmp_path / "repo"
|
|
repo.mkdir()
|
|
(repo / "SCOPE.md").write_text("# SCOPE\n", encoding="utf-8")
|
|
(repo / "INTENT.md").write_text("# INTENT\n\nKeep me.\n", encoding="utf-8")
|
|
|
|
result = bootstrap_intent_from_scope(repo)
|
|
|
|
assert result.status == "exists"
|
|
assert (repo / "INTENT.md").read_text(encoding="utf-8") == "# INTENT\n\nKeep me.\n"
|
|
|
|
|
|
def test_bootstrap_intent_from_scope_dry_run_reports_without_writing(tmp_path):
|
|
repo = tmp_path / "repo"
|
|
repo.mkdir()
|
|
(repo / "SCOPE.md").write_text("# SCOPE\n", encoding="utf-8")
|
|
|
|
result = bootstrap_intent_from_scope(repo, dry_run=True)
|
|
|
|
assert result.status == "would_create"
|
|
assert not (repo / "INTENT.md").exists()
|