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>
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""get_knowledge_counts includes the 'process' type and counts it in total."""
|
|
from unittest.mock import AsyncMock, MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
|
|
def _make_mock_session():
|
|
s = AsyncMock()
|
|
s.__aenter__ = AsyncMock(return_value=s)
|
|
s.__aexit__ = AsyncMock(return_value=False)
|
|
return s
|
|
|
|
|
|
def _grouped(rows):
|
|
r = MagicMock()
|
|
r.all.return_value = rows
|
|
return r
|
|
|
|
|
|
def _scalar(n):
|
|
r = MagicMock()
|
|
r.scalar_one.return_value = n
|
|
return r
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_counts_include_process_in_facet_and_total():
|
|
session = _make_mock_session()
|
|
# 1) grouped non-task counts, 2) task count, 3) plan count
|
|
session.execute = AsyncMock(side_effect=[
|
|
_grouped([("note", 3), ("process", 2)]),
|
|
_scalar(1), # tasks
|
|
_scalar(0), # plans
|
|
])
|
|
with patch("scribe.services.knowledge.async_session") as cls:
|
|
cls.return_value = session
|
|
from scribe.services.knowledge import get_knowledge_counts
|
|
counts = await get_knowledge_counts(user_id=1)
|
|
|
|
assert counts["process"] == 2
|
|
# facet keys all present (setdefault)
|
|
for key in ("note", "person", "place", "list", "task", "plan", "process"):
|
|
assert key in counts
|
|
# total = note(3) + person(0) + place(0) + list(0) + task(1) + process(2)
|
|
assert counts["total"] == 6
|