refactor: rename package fabledassistant -> scribe (code-only)
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>
This commit is contained in:
@@ -4,8 +4,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from fabledassistant.mcp._context import _user_id_ctx
|
||||
from fabledassistant.mcp.tools.tasks import (
|
||||
from scribe.mcp._context import _user_id_ctx
|
||||
from scribe.mcp.tools.tasks import (
|
||||
list_tasks, get_task, create_task,
|
||||
update_task, add_task_log,
|
||||
)
|
||||
@@ -36,7 +36,7 @@ def _fake_task(*, parent_id: int | None = None, **overrides) -> MagicMock:
|
||||
async def test_list_tasks_passes_is_task_true_and_repackages():
|
||||
rows = [_fake_task(id=1), _fake_task(id=2)]
|
||||
mock = AsyncMock(return_value=(rows, 2))
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.list_notes", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.list_notes", mock):
|
||||
out = await list_tasks()
|
||||
assert out["total"] == 2
|
||||
assert len(out["tasks"]) == 2
|
||||
@@ -46,7 +46,7 @@ async def test_list_tasks_passes_is_task_true_and_repackages():
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_tasks_status_filter():
|
||||
mock = AsyncMock(return_value=([], 0))
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.list_notes", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.list_notes", mock):
|
||||
await list_tasks(status="in_progress")
|
||||
assert mock.call_args.kwargs["status"] == "in_progress"
|
||||
|
||||
@@ -54,7 +54,7 @@ async def test_list_tasks_status_filter():
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_tasks_empty_status_means_no_filter():
|
||||
mock = AsyncMock(return_value=([], 0))
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.list_notes", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.list_notes", mock):
|
||||
await list_tasks(status="")
|
||||
assert mock.call_args.kwargs["status"] is None
|
||||
|
||||
@@ -63,7 +63,7 @@ async def test_list_tasks_empty_status_means_no_filter():
|
||||
async def test_get_task_with_no_parent_returns_null_parent_title():
|
||||
fake = _fake_task(id=5, title="solo", parent_id=None)
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.tasks.notes_svc.get_note",
|
||||
"scribe.mcp.tools.tasks.notes_svc.get_note",
|
||||
AsyncMock(return_value=fake),
|
||||
):
|
||||
out = await get_task(task_id=5)
|
||||
@@ -78,7 +78,7 @@ async def test_get_task_enriches_with_parent_title():
|
||||
parent = _fake_task(id=5, title="parent of 10", parent_id=None)
|
||||
# get_note is called twice: once for child, once for parent
|
||||
mock_get = AsyncMock(side_effect=[child, parent])
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.get_note", mock_get):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.get_note", mock_get):
|
||||
out = await get_task(task_id=10)
|
||||
assert out["parent_title"] == "parent of 10"
|
||||
assert mock_get.await_count == 2
|
||||
@@ -89,7 +89,7 @@ async def test_get_task_parent_missing_returns_null():
|
||||
"""If parent_id is set but the parent is gone (orphaned), parent_title is None."""
|
||||
child = _fake_task(id=10, parent_id=5)
|
||||
mock_get = AsyncMock(side_effect=[child, None])
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.get_note", mock_get):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.get_note", mock_get):
|
||||
out = await get_task(task_id=10)
|
||||
assert out["parent_title"] is None
|
||||
|
||||
@@ -97,7 +97,7 @@ async def test_get_task_parent_missing_returns_null():
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_task_raises_when_not_found():
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.tasks.notes_svc.get_note",
|
||||
"scribe.mcp.tools.tasks.notes_svc.get_note",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
with pytest.raises(ValueError, match="task 999 not found"):
|
||||
@@ -108,7 +108,7 @@ async def test_get_task_raises_when_not_found():
|
||||
async def test_create_task_passes_status():
|
||||
fake = _fake_task()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.create_note", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.create_note", mock):
|
||||
await create_task(title="do x", status="todo")
|
||||
assert mock.call_args.kwargs["status"] == "todo"
|
||||
|
||||
@@ -117,7 +117,7 @@ async def test_create_task_passes_status():
|
||||
async def test_create_task_priority_empty_becomes_none():
|
||||
fake = _fake_task()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.create_note", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.create_note", mock):
|
||||
await create_task(title="x", priority="")
|
||||
assert mock.call_args.kwargs["priority"] is None
|
||||
|
||||
@@ -126,7 +126,7 @@ async def test_create_task_priority_empty_becomes_none():
|
||||
async def test_create_task_zero_id_sentinels_become_none():
|
||||
fake = _fake_task()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.create_note", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.create_note", mock):
|
||||
await create_task(title="x", project_id=0, milestone_id=0, parent_id=0)
|
||||
assert mock.call_args.kwargs["project_id"] is None
|
||||
assert mock.call_args.kwargs["milestone_id"] is None
|
||||
@@ -137,7 +137,7 @@ async def test_create_task_zero_id_sentinels_become_none():
|
||||
async def test_update_task_only_sends_non_default_fields():
|
||||
fake = _fake_task()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
await update_task(task_id=1, status="done")
|
||||
args, kwargs = mock.call_args
|
||||
assert args == (7, 1)
|
||||
@@ -149,7 +149,7 @@ async def test_update_task_empty_priority_is_omitted():
|
||||
"""Priority="" is "leave unchanged" — must not reach service as empty string."""
|
||||
fake = _fake_task()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
await update_task(task_id=1, status="done", priority="")
|
||||
assert "priority" not in mock.call_args.kwargs
|
||||
|
||||
@@ -157,7 +157,7 @@ async def test_update_task_empty_priority_is_omitted():
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_task_raises_when_not_found():
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.tasks.notes_svc.update_note",
|
||||
"scribe.mcp.tools.tasks.notes_svc.update_note",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
with pytest.raises(ValueError, match="task 999 not found"):
|
||||
@@ -169,7 +169,7 @@ async def test_update_task_milestone_zero_is_omitted():
|
||||
"""milestone_id=0 is 'leave unchanged' — must not reach the service."""
|
||||
fake = _fake_task()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
await update_task(task_id=1, milestone_id=0)
|
||||
assert "milestone_id" not in mock.call_args.kwargs
|
||||
|
||||
@@ -178,7 +178,7 @@ async def test_update_task_milestone_zero_is_omitted():
|
||||
async def test_update_task_milestone_positive_is_set():
|
||||
fake = _fake_task()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
await update_task(task_id=1, milestone_id=42)
|
||||
assert mock.call_args.kwargs["milestone_id"] == 42
|
||||
|
||||
@@ -188,7 +188,7 @@ async def test_update_task_milestone_negative_one_clears():
|
||||
"""milestone_id=-1 clears the milestone (sets the column NULL)."""
|
||||
fake = _fake_task()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
await update_task(task_id=1, milestone_id=-1)
|
||||
assert mock.call_args.kwargs["milestone_id"] is None
|
||||
|
||||
@@ -198,7 +198,7 @@ async def test_update_task_clearing_project_also_clears_milestone():
|
||||
"""project_id=-1 clears the project and, with it, the milestone."""
|
||||
fake = _fake_task()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
with patch("scribe.mcp.tools.tasks.notes_svc.update_note", mock):
|
||||
await update_task(task_id=1, project_id=-1)
|
||||
assert mock.call_args.kwargs["project_id"] is None
|
||||
assert mock.call_args.kwargs["milestone_id"] is None
|
||||
@@ -214,7 +214,7 @@ async def test_add_task_log_returns_log_dict():
|
||||
# No to_dict on TaskLog model (per task_logs.py inspection) — fall through to manual dict
|
||||
del log.to_dict
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.tasks.task_logs_svc.create_log",
|
||||
"scribe.mcp.tools.tasks.task_logs_svc.create_log",
|
||||
AsyncMock(return_value=log),
|
||||
):
|
||||
out = await add_task_log(task_id=1, content="checkpoint")
|
||||
@@ -228,7 +228,7 @@ async def test_add_task_log_returns_log_dict():
|
||||
async def test_add_task_log_propagates_value_error_when_task_missing():
|
||||
"""create_log raises ValueError if the task doesn't exist; we let it through."""
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.tasks.task_logs_svc.create_log",
|
||||
"scribe.mcp.tools.tasks.task_logs_svc.create_log",
|
||||
AsyncMock(side_effect=ValueError("Task 999 not found")),
|
||||
):
|
||||
with pytest.raises(ValueError):
|
||||
|
||||
Reference in New Issue
Block a user