diff --git a/tests/test_mcp_tool_systems.py b/tests/test_mcp_tool_systems.py index 3656b8a..73c10a1 100644 --- a/tests/test_mcp_tool_systems.py +++ b/tests/test_mcp_tool_systems.py @@ -106,6 +106,7 @@ async def test_untagged_hint_zero_systems_prompts_first_create_and_fails_open(): @pytest.mark.asyncio async def test_create_system_same_normalized_name_is_duplicate_gated(): existing = _fake_system(sid=7, name="Scrape Pipeline") + existing.id = 7 existing.name = "Scrape Pipeline" with patch("scribe.mcp.tools.systems.current_user_id", return_value=1), \ patch("scribe.mcp.tools.systems.systems_svc") as svc: @@ -150,7 +151,10 @@ async def test_create_task_untagged_in_project_carries_the_question(): @pytest.mark.asyncio async def test_create_task_tagged_shows_systems_and_projectless_gets_neither(): - note = MagicMock(); note.id = 61; note.to_dict.return_value = {"id": 61} + note = MagicMock(); note.id = 61 + # Fresh dict per call — a shared return_value dict lets the first create's + # mutation leak into the second create's response. + note.to_dict.side_effect = lambda: {"id": 61} tagged_sys = MagicMock(); tagged_sys.to_dict.return_value = {"id": 4, "name": "plugin-hooks"} with patch("scribe.mcp.tools.tasks.current_user_id", return_value=1), \ patch("scribe.mcp.tools.tasks.notes_svc") as notes_svc, \