b255a0f90e
Renames src/fabledassistant -> src/scribe and all imports, plus the default DB name and DB user/password (fabled -> scribe) in config + compose. 952 refs / 154 files. Reverses the old 'internal name stays fabledassistant' convention. Code-only: live databases are still physically named 'fabledassistant'. Deployed environments must set POSTGRES_DB / POSTGRES_USER (or rename the DB) since the defaults now resolve to 'scribe'. Repo (FabledScribe), git host (fabledsword), MCP (fabled-git) and the image name (fabledscribe) are intentionally unchanged. ruff check src/ clean locally; CI (typecheck + pytest) is the gate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
2.1 KiB
Python
47 lines
2.1 KiB
Python
from unittest.mock import AsyncMock, MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_start_planning_creates_plan_task_and_returns_rules():
|
|
fake_note = MagicMock()
|
|
fake_note.to_dict.return_value = {"id": 5, "title": "Plan it", "task_kind": "plan"}
|
|
applicable = {
|
|
"rules": [{"id": 1, "title": "dev is home", "statement": "...",
|
|
"topic_title": "git-workflow", "rulebook_title": "FabledSword family"}],
|
|
"truncated": False,
|
|
"subscribed_rulebooks": [{"id": 2, "title": "FabledSword family"}],
|
|
}
|
|
with patch("scribe.services.planning.notes_svc.create_note",
|
|
AsyncMock(return_value=fake_note)) as mock_create, \
|
|
patch("scribe.services.planning.rulebooks_svc.get_applicable_rules",
|
|
AsyncMock(return_value=applicable)), \
|
|
patch("scribe.services.planning.notes_svc.list_notes",
|
|
AsyncMock(return_value=([], 3))), \
|
|
patch("scribe.services.planning.projects_svc.get_project",
|
|
AsyncMock(return_value=MagicMock(goal="ship it"))):
|
|
from scribe.services.planning import start_planning
|
|
out = await start_planning(user_id=7, project_id=3, title="Plan it")
|
|
|
|
# Created a plan-task (status set => task, kind=plan)
|
|
kwargs = mock_create.call_args.kwargs
|
|
assert kwargs["task_kind"] == "plan"
|
|
assert kwargs["status"] == "todo"
|
|
assert kwargs["project_id"] == 3
|
|
assert "## Goal" in kwargs["body"] # seeded template
|
|
# Returned shape
|
|
assert out["task"]["id"] == 5
|
|
assert out["applicable_rules"][0]["title"] == "dev is home"
|
|
assert out["subscribed_rulebooks"] == [{"id": 2, "title": "FabledSword family"}]
|
|
assert out["open_task_count"] == 3
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_start_planning_raises_when_project_not_found():
|
|
with patch("scribe.services.planning.projects_svc.get_project",
|
|
AsyncMock(return_value=None)):
|
|
from scribe.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")
|