mirror of
https://github.com/jmagar/unraid-mcp.git
synced 2026-03-23 12:39:24 -07:00
fix(notifications): remove warnings action (warningsAndAlerts not in live API)
This commit is contained in:
@@ -1,12 +1,20 @@
|
|||||||
"""Tests for unraid_notifications tool."""
|
"""Tests for unraid_notifications tool."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
|
from typing import get_args
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from conftest import make_tool_fn
|
from conftest import make_tool_fn
|
||||||
|
|
||||||
from unraid_mcp.core.exceptions import ToolError
|
from unraid_mcp.core.exceptions import ToolError
|
||||||
|
from unraid_mcp.tools.notifications import NOTIFICATION_ACTIONS
|
||||||
|
|
||||||
|
|
||||||
|
def test_warnings_action_removed() -> None:
|
||||||
|
assert "warnings" not in get_args(NOTIFICATION_ACTIONS), (
|
||||||
|
"warnings action references warningsAndAlerts which is not in live API"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -72,14 +80,6 @@ class TestNotificationsActions:
|
|||||||
result = await tool_fn(action="list")
|
result = await tool_fn(action="list")
|
||||||
assert len(result["notifications"]) == 1
|
assert len(result["notifications"]) == 1
|
||||||
|
|
||||||
async def test_warnings(self, _mock_graphql: AsyncMock) -> None:
|
|
||||||
_mock_graphql.return_value = {
|
|
||||||
"notifications": {"warningsAndAlerts": [{"id": "n:1", "importance": "WARNING"}]}
|
|
||||||
}
|
|
||||||
tool_fn = _make_tool()
|
|
||||||
result = await tool_fn(action="warnings")
|
|
||||||
assert len(result["warnings"]) == 1
|
|
||||||
|
|
||||||
async def test_create(self, _mock_graphql: AsyncMock) -> None:
|
async def test_create(self, _mock_graphql: AsyncMock) -> None:
|
||||||
_mock_graphql.return_value = {
|
_mock_graphql.return_value = {
|
||||||
"createNotification": {"id": "n:new", "title": "Test", "importance": "INFO"}
|
"createNotification": {"id": "n:new", "title": "Test", "importance": "INFO"}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Notification management.
|
"""Notification management.
|
||||||
|
|
||||||
Provides the `unraid_notifications` tool with 9 actions for viewing,
|
Provides the `unraid_notifications` tool with 13 actions for viewing,
|
||||||
creating, archiving, and deleting system notifications.
|
creating, archiving, and deleting system notifications.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -33,13 +33,6 @@ QUERIES: dict[str, str] = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
"warnings": """
|
|
||||||
query GetWarningsAndAlerts {
|
|
||||||
notifications {
|
|
||||||
warningsAndAlerts { id title subject description importance type timestamp }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
""",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MUTATIONS: dict[str, str] = {
|
MUTATIONS: dict[str, str] = {
|
||||||
@@ -128,7 +121,6 @@ _VALID_IMPORTANCE = {"ALERT", "WARNING", "INFO"}
|
|||||||
NOTIFICATION_ACTIONS = Literal[
|
NOTIFICATION_ACTIONS = Literal[
|
||||||
"overview",
|
"overview",
|
||||||
"list",
|
"list",
|
||||||
"warnings",
|
|
||||||
"create",
|
"create",
|
||||||
"archive",
|
"archive",
|
||||||
"unread",
|
"unread",
|
||||||
@@ -174,7 +166,6 @@ def register_notifications_tool(mcp: FastMCP) -> None:
|
|||||||
Actions:
|
Actions:
|
||||||
overview - Notification counts by severity (unread/archive)
|
overview - Notification counts by severity (unread/archive)
|
||||||
list - List notifications with filtering (list_type=UNREAD/ARCHIVE, importance=INFO/WARNING/ALERT)
|
list - List notifications with filtering (list_type=UNREAD/ARCHIVE, importance=INFO/WARNING/ALERT)
|
||||||
warnings - Get deduplicated unread warnings and alerts
|
|
||||||
create - Create notification (requires title, subject, description, importance)
|
create - Create notification (requires title, subject, description, importance)
|
||||||
archive - Archive a notification (requires notification_id)
|
archive - Archive a notification (requires notification_id)
|
||||||
unread - Mark notification as unread (requires notification_id)
|
unread - Mark notification as unread (requires notification_id)
|
||||||
@@ -233,11 +224,6 @@ def register_notifications_tool(mcp: FastMCP) -> None:
|
|||||||
notifications = data.get("notifications", {})
|
notifications = data.get("notifications", {})
|
||||||
return {"notifications": notifications.get("list", [])}
|
return {"notifications": notifications.get("list", [])}
|
||||||
|
|
||||||
if action == "warnings":
|
|
||||||
data = await make_graphql_request(QUERIES["warnings"])
|
|
||||||
notifications = data.get("notifications", {})
|
|
||||||
return {"warnings": notifications.get("warningsAndAlerts", [])}
|
|
||||||
|
|
||||||
if action == "create":
|
if action == "create":
|
||||||
if title is None or subject is None or description is None or importance is None:
|
if title is None or subject is None or description is None or importance is None:
|
||||||
raise ToolError("create requires title, subject, description, and importance")
|
raise ToolError("create requires title, subject, description, and importance")
|
||||||
|
|||||||
Reference in New Issue
Block a user