CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 8s
CI & Build / integration (push) Successful in 24s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 54s
CI & Build / Build & push image (push) Successful in 18s
The shape ledger showed the same test scaffolding defined over and over: _bind_user x12 (byte-identical), _dispose_engine x10 in three wordings, _no_supersession x3, _make_mock_session x7 in three subsets, a get-or-create User helper x2 (+3 inlined), and fifteen hand-rolled MagicMock note factories each re-explaining the same "an auto-MagicMock attribute is truthy" hazard (note 2109). Now: conftest.py carries _bind_user / _dispose_engine / _no_supersession as opt-in fixtures (pytestmark = usefixtures(...) per module, so unit tests pay nothing), and tests/helpers.py carries make_mock_session(), ensure_user() and fake_note(**attrs) — the hazard documented once, real values on every attribute the product reads. Call sites were rewritten by AST so titles with dashes and commas survived; the three SimpleNamespace _note stand-ins that only feed a single function stay local. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from unittest.mock import AsyncMock, patch
|
|
|
|
import pytest
|
|
from tests.helpers import fake_note
|
|
|
|
|
|
pytestmark = pytest.mark.usefixtures("_bind_user")
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_create_task_passes_kind():
|
|
# kind=plan is retired (plans are milestones); 'issue' exercises passthrough.
|
|
mock = AsyncMock(return_value=fake_note(task_kind="issue"))
|
|
with patch("scribe.mcp.tools.tasks.notes_svc.create_note", mock):
|
|
from scribe.mcp.tools.tasks import create_task
|
|
await create_task(title="P", kind="issue")
|
|
assert mock.call_args.kwargs["task_kind"] == "issue"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_tasks_passes_kind_filter():
|
|
mock = AsyncMock(return_value=([], 0))
|
|
with patch("scribe.mcp.tools.tasks.notes_svc.list_notes", mock):
|
|
from scribe.mcp.tools.tasks import list_tasks
|
|
await list_tasks(kind="plan")
|
|
assert mock.call_args.kwargs["task_kind"] == "plan"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_tasks_kind_empty_means_no_filter():
|
|
mock = AsyncMock(return_value=([], 0))
|
|
with patch("scribe.mcp.tools.tasks.notes_svc.list_notes", mock):
|
|
from scribe.mcp.tools.tasks import list_tasks
|
|
await list_tasks()
|
|
assert mock.call_args.kwargs["task_kind"] is None
|