From b68347bc1e2a6fde9327c9a2222131a6d35b02c8 Mon Sep 17 00:00:00 2001 From: Jacob Magar Date: Sun, 15 Mar 2026 19:32:17 -0400 Subject: [PATCH] refactor(tests): remove duplicate fixture in test_array.py, unify on _mock_graphql --- tests/test_array.py | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/tests/test_array.py b/tests/test_array.py index 80adbfe..041ab5f 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -148,18 +148,12 @@ class TestArrayNetworkErrors: # --------------------------------------------------------------------------- -@pytest.fixture -def _mock_array_graphql(): - with patch("unraid_mcp.tools.array.make_graphql_request", new_callable=AsyncMock) as m: - yield m - - # parity_history @pytest.mark.asyncio -async def test_parity_history_returns_history(_mock_array_graphql): - _mock_array_graphql.return_value = { +async def test_parity_history_returns_history(_mock_graphql): + _mock_graphql.return_value = { "parityHistory": [{"date": "2026-03-01T00:00:00Z", "status": "COMPLETED", "errors": 0}] } result = await _make_tool()(action="parity_history") @@ -171,15 +165,15 @@ async def test_parity_history_returns_history(_mock_array_graphql): @pytest.mark.asyncio -async def test_start_array(_mock_array_graphql): - _mock_array_graphql.return_value = {"array": {"setState": {"state": "STARTED"}}} +async def test_start_array(_mock_graphql): + _mock_graphql.return_value = {"array": {"setState": {"state": "STARTED"}}} result = await _make_tool()(action="start_array") assert result["success"] is True @pytest.mark.asyncio -async def test_stop_array(_mock_array_graphql): - _mock_array_graphql.return_value = {"array": {"setState": {"state": "STOPPED"}}} +async def test_stop_array(_mock_graphql): + _mock_graphql.return_value = {"array": {"setState": {"state": "STOPPED"}}} result = await _make_tool()(action="stop_array") assert result["success"] is True @@ -188,14 +182,14 @@ async def test_stop_array(_mock_array_graphql): @pytest.mark.asyncio -async def test_add_disk_requires_disk_id(_mock_array_graphql): +async def test_add_disk_requires_disk_id(_mock_graphql): with pytest.raises(ToolError, match="disk_id"): await _make_tool()(action="add_disk") @pytest.mark.asyncio -async def test_add_disk_success(_mock_array_graphql): - _mock_array_graphql.return_value = {"array": {"addDiskToArray": {"state": "STARTED"}}} +async def test_add_disk_success(_mock_graphql): + _mock_graphql.return_value = {"array": {"addDiskToArray": {"state": "STARTED"}}} result = await _make_tool()(action="add_disk", disk_id="abc123:local") assert result["success"] is True @@ -204,14 +198,14 @@ async def test_add_disk_success(_mock_array_graphql): @pytest.mark.asyncio -async def test_remove_disk_requires_confirm(_mock_array_graphql): +async def test_remove_disk_requires_confirm(_mock_graphql): with pytest.raises(ToolError, match="not confirmed"): await _make_tool()(action="remove_disk", disk_id="abc123:local", confirm=False) @pytest.mark.asyncio -async def test_remove_disk_with_confirm(_mock_array_graphql): - _mock_array_graphql.return_value = {"array": {"removeDiskFromArray": {"state": "STOPPED"}}} +async def test_remove_disk_with_confirm(_mock_graphql): + _mock_graphql.return_value = {"array": {"removeDiskFromArray": {"state": "STOPPED"}}} result = await _make_tool()(action="remove_disk", disk_id="abc123:local", confirm=True) assert result["success"] is True @@ -220,14 +214,14 @@ async def test_remove_disk_with_confirm(_mock_array_graphql): @pytest.mark.asyncio -async def test_mount_disk_requires_disk_id(_mock_array_graphql): +async def test_mount_disk_requires_disk_id(_mock_graphql): with pytest.raises(ToolError, match="disk_id"): await _make_tool()(action="mount_disk") @pytest.mark.asyncio -async def test_unmount_disk_success(_mock_array_graphql): - _mock_array_graphql.return_value = {"array": {"unmountArrayDisk": {"id": "abc123:local"}}} +async def test_unmount_disk_success(_mock_graphql): + _mock_graphql.return_value = {"array": {"unmountArrayDisk": {"id": "abc123:local"}}} result = await _make_tool()(action="unmount_disk", disk_id="abc123:local") assert result["success"] is True @@ -236,13 +230,13 @@ async def test_unmount_disk_success(_mock_array_graphql): @pytest.mark.asyncio -async def test_clear_disk_stats_requires_confirm(_mock_array_graphql): +async def test_clear_disk_stats_requires_confirm(_mock_graphql): with pytest.raises(ToolError, match="not confirmed"): await _make_tool()(action="clear_disk_stats", disk_id="abc123:local", confirm=False) @pytest.mark.asyncio -async def test_clear_disk_stats_with_confirm(_mock_array_graphql): - _mock_array_graphql.return_value = {"array": {"clearArrayDiskStatistics": True}} +async def test_clear_disk_stats_with_confirm(_mock_graphql): + _mock_graphql.return_value = {"array": {"clearArrayDiskStatistics": True}} result = await _make_tool()(action="clear_disk_stats", disk_id="abc123:local", confirm=True) assert result["success"] is True