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:
@@ -49,10 +49,10 @@ def _make_mock_event(id=1, user_id=1, uid="uid-abc", title="Meeting",
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_event_stores_to_db():
|
||||
mock_session = _make_mock_session()
|
||||
with patch("fabledassistant.services.events.async_session") as mock_cls, \
|
||||
patch("fabledassistant.services.events.asyncio.create_task") as mock_task:
|
||||
with patch("scribe.services.events.async_session") as mock_cls, \
|
||||
patch("scribe.services.events.asyncio.create_task") as mock_task:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.events import create_event
|
||||
from scribe.services.events import create_event
|
||||
result = await create_event(
|
||||
user_id=1,
|
||||
title="Dentist",
|
||||
@@ -72,9 +72,9 @@ async def test_find_events_by_query_returns_ilike_results():
|
||||
mock_result.scalars.return_value.all.return_value = [mock_event]
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
|
||||
with patch("fabledassistant.services.events.async_session") as mock_cls:
|
||||
with patch("scribe.services.events.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.events import find_events_by_query
|
||||
from scribe.services.events import find_events_by_query
|
||||
results = await find_events_by_query(user_id=1, query="meeting")
|
||||
assert len(results) == 1
|
||||
assert results[0].title == "Team Meeting"
|
||||
@@ -88,9 +88,9 @@ async def test_list_events_returns_events_in_range():
|
||||
mock_result.scalars.return_value.all.return_value = [mock_event]
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
|
||||
with patch("fabledassistant.services.events.async_session") as mock_cls:
|
||||
with patch("scribe.services.events.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.events import list_events
|
||||
from scribe.services.events import list_events
|
||||
results = await list_events(
|
||||
user_id=1,
|
||||
date_from=datetime(2026, 3, 1, tzinfo=timezone.utc),
|
||||
@@ -107,10 +107,10 @@ async def test_delete_event_fires_caldav_push_when_uid_set():
|
||||
mock_result.scalar_one_or_none.return_value = mock_event
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
|
||||
with patch("fabledassistant.services.events.async_session") as mock_cls, \
|
||||
patch("fabledassistant.services.events.asyncio.create_task") as mock_task:
|
||||
with patch("scribe.services.events.async_session") as mock_cls, \
|
||||
patch("scribe.services.events.asyncio.create_task") as mock_task:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.events import delete_event
|
||||
from scribe.services.events import delete_event
|
||||
await delete_event(user_id=1, event_id=1)
|
||||
# Push task fired because caldav_uid is set
|
||||
assert mock_task.called
|
||||
@@ -124,10 +124,10 @@ async def test_update_event_fires_caldav_push():
|
||||
mock_result.scalar_one_or_none.return_value = mock_event
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
|
||||
with patch("fabledassistant.services.events.async_session") as mock_cls, \
|
||||
patch("fabledassistant.services.events.asyncio.create_task") as mock_task:
|
||||
with patch("scribe.services.events.async_session") as mock_cls, \
|
||||
patch("scribe.services.events.asyncio.create_task") as mock_task:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.events import update_event
|
||||
from scribe.services.events import update_event
|
||||
await update_event(user_id=1, event_id=1, title="Updated Title")
|
||||
assert mock_task.called
|
||||
|
||||
@@ -137,7 +137,7 @@ async def test_update_event_fires_caldav_push():
|
||||
|
||||
def test_normalize_duration_from_end_dt():
|
||||
"""end_dt sugar converts to a positive minute count anchored on start."""
|
||||
from fabledassistant.services.events import _normalize_duration
|
||||
from scribe.services.events import _normalize_duration
|
||||
start = datetime(2026, 5, 1, 8, 0, tzinfo=timezone.utc)
|
||||
end = datetime(2026, 5, 1, 9, 30, tzinfo=timezone.utc)
|
||||
assert _normalize_duration(start_dt=start, end_dt=end, duration_minutes=None) == 90
|
||||
@@ -147,7 +147,7 @@ def test_normalize_duration_zero_is_valid_point_event():
|
||||
"""end_dt == start_dt → duration 0. The point-with-zero-duration case
|
||||
is rare but legal (e.g. an instant marker); the duration model treats
|
||||
it the same as duration None for display purposes."""
|
||||
from fabledassistant.services.events import _normalize_duration
|
||||
from scribe.services.events import _normalize_duration
|
||||
same = datetime(2026, 5, 1, 8, 0, tzinfo=timezone.utc)
|
||||
assert _normalize_duration(start_dt=same, end_dt=same, duration_minutes=None) == 0
|
||||
|
||||
@@ -158,7 +158,7 @@ def test_normalize_duration_rejects_end_before_start():
|
||||
via a CHECK constraint, but write-path callers still get a
|
||||
helpful ValueError if they construct an inconsistent (start, end)
|
||||
pair via the end_dt sugar."""
|
||||
from fabledassistant.services.events import _normalize_duration
|
||||
from scribe.services.events import _normalize_duration
|
||||
start = datetime(2026, 5, 1, 12, 0, tzinfo=timezone.utc)
|
||||
end_before = datetime(2026, 3, 30, 12, 0, tzinfo=timezone.utc)
|
||||
with pytest.raises(ValueError, match="at or after start_dt"):
|
||||
@@ -171,7 +171,7 @@ def test_normalize_duration_rejects_negative_duration():
|
||||
"""Direct duration_minutes < 0 is rejected. Mirrors the DB CHECK
|
||||
constraint at the service boundary so callers get a clean error
|
||||
rather than a constraint violation from psycopg."""
|
||||
from fabledassistant.services.events import _normalize_duration
|
||||
from scribe.services.events import _normalize_duration
|
||||
start = datetime(2026, 5, 1, 12, 0, tzinfo=timezone.utc)
|
||||
with pytest.raises(ValueError, match="must be >= 0"):
|
||||
_normalize_duration(start_dt=start, end_dt=None, duration_minutes=-15)
|
||||
@@ -180,7 +180,7 @@ def test_normalize_duration_rejects_negative_duration():
|
||||
def test_normalize_duration_rejects_inconsistent_end_and_duration():
|
||||
"""If a caller passes both end_dt AND duration_minutes that disagree,
|
||||
the inconsistency is surfaced rather than silently picking one."""
|
||||
from fabledassistant.services.events import _normalize_duration
|
||||
from scribe.services.events import _normalize_duration
|
||||
start = datetime(2026, 5, 1, 12, 0, tzinfo=timezone.utc)
|
||||
end = datetime(2026, 5, 1, 13, 0, tzinfo=timezone.utc) # implies 60 min
|
||||
with pytest.raises(ValueError, match="implies 60 minutes"):
|
||||
@@ -191,7 +191,7 @@ def test_normalize_duration_rejects_inconsistent_end_and_duration():
|
||||
|
||||
def test_normalize_duration_none_for_open_ended():
|
||||
"""Both inputs None → None duration (open-ended event)."""
|
||||
from fabledassistant.services.events import _normalize_duration
|
||||
from scribe.services.events import _normalize_duration
|
||||
start = datetime(2026, 5, 1, 12, 0, tzinfo=timezone.utc)
|
||||
assert _normalize_duration(
|
||||
start_dt=start, end_dt=None, duration_minutes=None,
|
||||
@@ -202,7 +202,7 @@ def test_normalize_duration_none_for_open_ended():
|
||||
async def test_create_event_rejects_end_before_start():
|
||||
"""Service-level rejection — same scenario as the prod bug, surfaced
|
||||
cleanly for tool / route callers via ValueError."""
|
||||
from fabledassistant.services.events import create_event
|
||||
from scribe.services.events import create_event
|
||||
start = datetime(2026, 5, 1, 12, 0, tzinfo=timezone.utc)
|
||||
end_before = datetime(2026, 3, 30, 12, 0, tzinfo=timezone.utc)
|
||||
with pytest.raises(ValueError, match="at or after start_dt"):
|
||||
@@ -225,10 +225,10 @@ async def test_update_event_preserves_duration_when_only_start_changes():
|
||||
mock_result.scalar_one_or_none.return_value = mock_event
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
|
||||
with patch("fabledassistant.services.events.async_session") as mock_cls, \
|
||||
patch("fabledassistant.services.events.asyncio.create_task"):
|
||||
with patch("scribe.services.events.async_session") as mock_cls, \
|
||||
patch("scribe.services.events.asyncio.create_task"):
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.events import update_event
|
||||
from scribe.services.events import update_event
|
||||
# Move start to 12:00; effective end becomes 13:00 automatically.
|
||||
result = await update_event(
|
||||
user_id=1, event_id=1,
|
||||
@@ -251,10 +251,10 @@ async def test_update_event_clearing_end_dt_clears_duration():
|
||||
mock_result.scalar_one_or_none.return_value = mock_event
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
|
||||
with patch("fabledassistant.services.events.async_session") as mock_cls, \
|
||||
patch("fabledassistant.services.events.asyncio.create_task"):
|
||||
with patch("scribe.services.events.async_session") as mock_cls, \
|
||||
patch("scribe.services.events.asyncio.create_task"):
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.events import update_event
|
||||
from scribe.services.events import update_event
|
||||
await update_event(user_id=1, event_id=1, end_dt=None)
|
||||
assert mock_event.duration_minutes is None
|
||||
|
||||
@@ -280,9 +280,9 @@ async def test_list_events_includes_point_event_in_window():
|
||||
mock_result.scalars.return_value.all.return_value = [mock_event]
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
|
||||
with patch("fabledassistant.services.events.async_session") as mock_cls:
|
||||
with patch("scribe.services.events.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.events import list_events
|
||||
from scribe.services.events import list_events
|
||||
results = await list_events(
|
||||
user_id=1,
|
||||
date_from=datetime(2026, 4, 29, tzinfo=timezone.utc),
|
||||
@@ -310,9 +310,9 @@ async def test_list_events_excludes_timed_event_that_already_ended():
|
||||
mock_result.scalars.return_value.all.return_value = [mock_event]
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
|
||||
with patch("fabledassistant.services.events.async_session") as mock_cls:
|
||||
with patch("scribe.services.events.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.events import list_events
|
||||
from scribe.services.events import list_events
|
||||
results = await list_events(
|
||||
user_id=1,
|
||||
date_from=datetime(2026, 4, 29, tzinfo=timezone.utc),
|
||||
|
||||
Reference in New Issue
Block a user