test(trash): update delete-tool tests to soft-delete contract (patch trash_svc.delete)

This commit is contained in:
2026-05-29 09:24:58 -04:00
parent bfeed67cfe
commit a40334312f
3 changed files with 16 additions and 19 deletions
+5 -9
View File
@@ -139,23 +139,19 @@ async def test_update_event_raises_when_not_found():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_delete_event_checks_existence_then_returns_confirmation(): async def test_delete_event_soft_deletes_and_returns_batch():
fake = _fake_event()
with patch( with patch(
"fabledassistant.mcp.tools.events.events_svc.get_event", "fabledassistant.mcp.tools.events.trash_svc.delete",
AsyncMock(return_value=fake), AsyncMock(return_value="batch-1"),
), patch(
"fabledassistant.mcp.tools.events.events_svc.delete_event",
AsyncMock(return_value=None),
): ):
result = await delete_event(event_id=7) result = await delete_event(event_id=7)
assert result == "Event 7 deleted." assert result["deleted_batch_id"] == "batch-1"
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_delete_event_raises_when_not_found(): async def test_delete_event_raises_when_not_found():
with patch( with patch(
"fabledassistant.mcp.tools.events.events_svc.get_event", "fabledassistant.mcp.tools.events.trash_svc.delete",
AsyncMock(return_value=None), AsyncMock(return_value=None),
): ):
with pytest.raises(ValueError, match="event 999 not found"): with pytest.raises(ValueError, match="event 999 not found"):
+6 -6
View File
@@ -165,20 +165,20 @@ async def test_update_note_raises_when_not_found():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_delete_note_returns_confirmation_string(): async def test_delete_note_soft_deletes_and_returns_batch():
with patch( with patch(
"fabledassistant.mcp.tools.notes.notes_svc.delete_note", "fabledassistant.mcp.tools.notes.trash_svc.delete",
AsyncMock(return_value=True), AsyncMock(return_value="batch-1"),
): ):
result = await delete_note(note_id=7) result = await delete_note(note_id=7)
assert result == "Note 7 deleted." assert result["deleted_batch_id"] == "batch-1"
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_delete_note_raises_when_not_found(): async def test_delete_note_raises_when_not_found():
with patch( with patch(
"fabledassistant.mcp.tools.notes.notes_svc.delete_note", "fabledassistant.mcp.tools.notes.trash_svc.delete",
AsyncMock(return_value=False), AsyncMock(return_value=None),
): ):
with pytest.raises(ValueError, match="note 999 not found"): with pytest.raises(ValueError, match="note 999 not found"):
await delete_note(note_id=999) await delete_note(note_id=999)
+5 -4
View File
@@ -125,19 +125,20 @@ async def test_delete_rule_without_confirmed_returns_warning():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_delete_rule_with_confirmed_calls_service(): async def test_delete_rule_with_confirmed_soft_deletes():
rule = _fake_rule() rule = _fake_rule()
mock_delete = AsyncMock() mock_delete = AsyncMock(return_value="batch-1")
with patch( with patch(
"fabledassistant.mcp.tools.rulebooks.rulebooks_svc.get_rule", "fabledassistant.mcp.tools.rulebooks.rulebooks_svc.get_rule",
AsyncMock(return_value=rule), AsyncMock(return_value=rule),
), patch( ), patch(
"fabledassistant.mcp.tools.rulebooks.rulebooks_svc.delete_rule", "fabledassistant.mcp.tools.rulebooks.trash_svc.delete",
mock_delete, mock_delete,
): ):
from fabledassistant.mcp.tools.rulebooks import delete_rule from fabledassistant.mcp.tools.rulebooks import delete_rule
out = await delete_rule(rule_id=1, confirmed=True) out = await delete_rule(rule_id=1, confirmed=True)
assert out == {"deleted": 1} assert out["deleted"] == 1
assert out["deleted_batch_id"] == "batch-1"
assert mock_delete.called assert mock_delete.called