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:
@@ -3,8 +3,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from fabledassistant.mcp._context import _user_id_ctx
|
||||
from fabledassistant.mcp.tools.notes import (
|
||||
from scribe.mcp._context import _user_id_ctx
|
||||
from scribe.mcp.tools.notes import (
|
||||
list_notes, get_note, create_note,
|
||||
update_note, delete_note,
|
||||
)
|
||||
@@ -29,7 +29,7 @@ def _fake_note(**overrides) -> MagicMock:
|
||||
async def test_list_notes_repackages_tuple_into_dict():
|
||||
rows = [_fake_note(id=1), _fake_note(id=2)]
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.notes.notes_svc.list_notes",
|
||||
"scribe.mcp.tools.notes.notes_svc.list_notes",
|
||||
AsyncMock(return_value=(rows, 2)),
|
||||
):
|
||||
out = await list_notes()
|
||||
@@ -40,7 +40,7 @@ async def test_list_notes_repackages_tuple_into_dict():
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_notes_passes_is_task_false():
|
||||
mock = AsyncMock(return_value=([], 0))
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
await list_notes()
|
||||
assert mock.call_args.kwargs["is_task"] is False
|
||||
|
||||
@@ -49,7 +49,7 @@ async def test_list_notes_passes_is_task_false():
|
||||
async def test_list_notes_tag_filter_maps_to_list():
|
||||
"""The single-tag string param maps to a one-element list at the service layer."""
|
||||
mock = AsyncMock(return_value=([], 0))
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
await list_notes(tag="ops")
|
||||
assert mock.call_args.kwargs["tags"] == ["ops"]
|
||||
|
||||
@@ -57,7 +57,7 @@ async def test_list_notes_tag_filter_maps_to_list():
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_notes_empty_tag_means_no_filter():
|
||||
mock = AsyncMock(return_value=([], 0))
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
await list_notes(tag="")
|
||||
assert mock.call_args.kwargs["tags"] is None
|
||||
|
||||
@@ -65,7 +65,7 @@ async def test_list_notes_empty_tag_means_no_filter():
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_notes_search_text_maps_to_q():
|
||||
mock = AsyncMock(return_value=([], 0))
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
await list_notes(search_text="kafka")
|
||||
assert mock.call_args.kwargs["q"] == "kafka"
|
||||
|
||||
@@ -73,7 +73,7 @@ async def test_list_notes_search_text_maps_to_q():
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_notes_limit_clamped():
|
||||
mock = AsyncMock(return_value=([], 0))
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.list_notes", mock):
|
||||
await list_notes(limit=9999)
|
||||
assert mock.call_args.kwargs["limit"] == 100
|
||||
|
||||
@@ -82,7 +82,7 @@ async def test_list_notes_limit_clamped():
|
||||
async def test_get_note_returns_dict():
|
||||
fake = _fake_note(id=5, title="found")
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.notes.notes_svc.get_note",
|
||||
"scribe.mcp.tools.notes.notes_svc.get_note",
|
||||
AsyncMock(return_value=fake),
|
||||
):
|
||||
out = await get_note(note_id=5)
|
||||
@@ -93,7 +93,7 @@ async def test_get_note_returns_dict():
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_note_raises_when_not_found():
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.notes.notes_svc.get_note",
|
||||
"scribe.mcp.tools.notes.notes_svc.get_note",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
with pytest.raises(ValueError, match="note 999 not found"):
|
||||
@@ -104,7 +104,7 @@ async def test_get_note_raises_when_not_found():
|
||||
async def test_create_note_passes_through():
|
||||
fake = _fake_note(id=10, title="new")
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.create_note", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.create_note", mock):
|
||||
out = await create_note(title="new", body="x", tags=["a"], project_id=5)
|
||||
assert out["id"] == 10
|
||||
assert mock.call_args.kwargs["title"] == "new"
|
||||
@@ -116,7 +116,7 @@ async def test_create_note_project_zero_becomes_none():
|
||||
"""project_id=0 sentinel must become None at the service layer (orphan note)."""
|
||||
fake = _fake_note()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.create_note", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.create_note", mock):
|
||||
await create_note(title="t", project_id=0)
|
||||
assert mock.call_args.kwargs["project_id"] is None
|
||||
|
||||
@@ -127,7 +127,7 @@ async def test_update_note_only_sends_non_default_fields():
|
||||
overwrite real data with empty strings."""
|
||||
fake = _fake_note()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.update_note", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.update_note", mock):
|
||||
await update_note(note_id=1, title="new title")
|
||||
# Service got user_id, note_id positional + only the title kwarg
|
||||
args, kwargs = mock.call_args
|
||||
@@ -140,7 +140,7 @@ async def test_update_note_empty_tags_clears_explicitly():
|
||||
"""tags=[] is an explicit clear, distinct from tags=None (omit)."""
|
||||
fake = _fake_note()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.update_note", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.update_note", mock):
|
||||
await update_note(note_id=1, tags=[])
|
||||
assert mock.call_args.kwargs == {"tags": []}
|
||||
|
||||
@@ -149,7 +149,7 @@ async def test_update_note_empty_tags_clears_explicitly():
|
||||
async def test_update_note_tags_none_means_omit():
|
||||
fake = _fake_note()
|
||||
mock = AsyncMock(return_value=fake)
|
||||
with patch("fabledassistant.mcp.tools.notes.notes_svc.update_note", mock):
|
||||
with patch("scribe.mcp.tools.notes.notes_svc.update_note", mock):
|
||||
await update_note(note_id=1, tags=None)
|
||||
assert "tags" not in mock.call_args.kwargs
|
||||
|
||||
@@ -157,7 +157,7 @@ async def test_update_note_tags_none_means_omit():
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_note_raises_when_not_found():
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.notes.notes_svc.update_note",
|
||||
"scribe.mcp.tools.notes.notes_svc.update_note",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
with pytest.raises(ValueError, match="note 999 not found"):
|
||||
@@ -167,7 +167,7 @@ async def test_update_note_raises_when_not_found():
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_note_soft_deletes_and_returns_batch():
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.notes.trash_svc.delete",
|
||||
"scribe.mcp.tools.notes.trash_svc.delete",
|
||||
AsyncMock(return_value="batch-1"),
|
||||
):
|
||||
result = await delete_note(note_id=7)
|
||||
@@ -177,7 +177,7 @@ async def test_delete_note_soft_deletes_and_returns_batch():
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_note_raises_when_not_found():
|
||||
with patch(
|
||||
"fabledassistant.mcp.tools.notes.trash_svc.delete",
|
||||
"scribe.mcp.tools.notes.trash_svc.delete",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
with pytest.raises(ValueError, match="note 999 not found"):
|
||||
|
||||
Reference in New Issue
Block a user