test(processes): retarget the update_process patch at get_note_for_user
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 12s
CI & Build / integration (push) Successful in 21s
CI & Build / Python tests (push) Successful in 47s
CI & Build / Build & push image (push) Successful in 1m9s
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 12s
CI & Build / integration (push) Successful in 21s
CI & Build / Python tests (push) Successful in 47s
CI & Build / Build & push image (push) Successful in 1m9s
Run 2899: 1 failed, 402 passed. test_update_process_rejects_non_process_note still patched notes.get_note, which update_process no longer calls now that it resolves shares — so the real get_note_for_user ran and reached for a database. Retargeted at get_note_for_user (which returns (note, permission)), and added the companion case the new behaviour deserves: a viewer grant is refused with the read-only reason and never reaches update_note. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLwAaV4DQEmVyn496HnEvt
This commit is contained in:
@@ -89,14 +89,34 @@ async def test_get_process_not_found_raises():
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_update_process_rejects_non_process_note():
|
async def test_update_process_rejects_non_process_note():
|
||||||
|
# Resolves share-aware now, so the patch target is get_note_for_user, which
|
||||||
|
# returns (note, permission).
|
||||||
plain = _fake_note(id=3, note_type="note")
|
plain = _fake_note(id=3, note_type="note")
|
||||||
with patch("scribe.services.notes.get_note",
|
plain.deleted_at = None
|
||||||
AsyncMock(return_value=plain)):
|
with patch("scribe.services.notes.get_note_for_user",
|
||||||
|
AsyncMock(return_value=(plain, "owner"))):
|
||||||
from scribe.mcp.tools.processes import update_process
|
from scribe.mcp.tools.processes import update_process
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
await update_process(process_id=3, title="x")
|
await update_process(process_id=3, title="x")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_update_process_refuses_a_read_only_share_with_the_reason():
|
||||||
|
"""An editor grant lets the holder edit someone else's process; a viewer
|
||||||
|
grant must be refused, and saying "not found" about a process the caller can
|
||||||
|
open would just send them looking for a missing id."""
|
||||||
|
theirs = _fake_note(id=5, user_id=9)
|
||||||
|
theirs.deleted_at = None
|
||||||
|
with patch("scribe.services.notes.get_note_for_user",
|
||||||
|
AsyncMock(return_value=(theirs, "viewer"))), \
|
||||||
|
patch("scribe.services.access.can_write_note", AsyncMock(return_value=False)), \
|
||||||
|
patch("scribe.services.notes.update_note", AsyncMock()) as mock_update:
|
||||||
|
from scribe.mcp.tools.processes import update_process
|
||||||
|
with pytest.raises(ValueError, match="read-only"):
|
||||||
|
await update_process(process_id=5, title="x")
|
||||||
|
mock_update.assert_not_awaited()
|
||||||
|
|
||||||
|
|
||||||
def test_register_attaches_four_tools():
|
def test_register_attaches_four_tools():
|
||||||
from scribe.mcp.tools import processes
|
from scribe.mcp.tools import processes
|
||||||
names: list[str] = []
|
names: list[str] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user