CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 56s
CI & Build / integration (push) Successful in 1m4s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 44s
Step 2 of the Scribe -> Grimoire rename. - src/scribe -> src/grimoire, and every import, patch target, module path, hypercorn entry point and `python -m grimoire.restore` with it; pyproject, uv.lock and the frontend package are named grimoire. - Image git.fabledsword.com/bvandeusen/fabledgrimoire; CI's Postgres service runs as grimoire / grimoire_test. - Compose files default the DB user, database and (prod) volume to grimoire, each overridable from .env, so an install created as Scribe keeps its data by setting POSTGRES_USER, POSTGRES_DB and PGDATA_VOLUME. - Backups are written as grimoire-<ts>.tar with format grimoire-backup-tar. Archives named scribe-* with the scribe-backup-tar manifest still restore and are still counted at the destination (folder and S3), with tests. - Exports, the MCP auth realm, the ASGI scope key and the persistent logger carry the new name. Kept on purpose: the secret-sealing key label stays "scribe.secrets.v1", because every stored secret was derived under it. Plugin identity (plugin name, hooks, env vars, .scribe marker, skills) is step 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
from unittest.mock import AsyncMock, MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_start_planning_creates_milestone_and_returns_rules():
|
|
# start_planning now creates a MILESTONE (the plan container), not a
|
|
# kind=plan task; its body holds the seeded design template.
|
|
fake_milestone = MagicMock()
|
|
fake_milestone.to_dict.return_value = {"id": 5, "title": "Plan it", "status": "active"}
|
|
applicable = {
|
|
"rules": [{"id": 1, "title": "dev is home", "statement": "...",
|
|
"topic_title": "git-workflow", "rulebook_title": "FabledSword family"}],
|
|
"truncated": False,
|
|
"project_rules": [{"id": 3, "title": "own", "statement": "..."}],
|
|
}
|
|
with patch("grimoire.services.planning.milestones_svc.create_milestone",
|
|
AsyncMock(return_value=fake_milestone)) as mock_create, \
|
|
patch("grimoire.services.planning.rulebooks_svc.get_applicable_rules",
|
|
AsyncMock(return_value=applicable)), \
|
|
patch("grimoire.services.planning.notes_svc.list_notes",
|
|
AsyncMock(return_value=([], 3))), \
|
|
patch("grimoire.services.planning.projects_svc.get_project",
|
|
AsyncMock(return_value=MagicMock(goal="ship it"))):
|
|
from grimoire.services.planning import start_planning
|
|
out = await start_planning(user_id=7, project_id=3, title="Plan it")
|
|
|
|
# Created a milestone with the seeded plan-body template.
|
|
kwargs = mock_create.call_args.kwargs
|
|
assert kwargs["project_id"] == 3
|
|
assert kwargs["status"] == "active"
|
|
assert "## Goal" in kwargs["body"] # seeded template
|
|
# Returned shape
|
|
assert out["milestone"]["id"] == 5
|
|
assert out["applicable_rules"][0]["title"] == "dev is home"
|
|
assert out["project_rules"][0]["id"] == 3
|
|
assert "subscribed_rulebooks" not in out
|
|
assert out["open_task_count"] == 3
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_start_planning_raises_when_project_not_found():
|
|
with patch("grimoire.services.planning.projects_svc.get_project",
|
|
AsyncMock(return_value=None)):
|
|
from grimoire.services.planning import start_planning
|
|
with pytest.raises(ValueError, match="project 999 not found"):
|
|
await start_planning(user_id=7, project_id=999, title="x")
|