notify: Modul als push importieren (Werkzeug notify verdeckte es), Test ruft die Server-Werkzeuge

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 13:34:15 +02:00
co-authored by Claude Opus 5.5
parent eb1d114762
commit a189db67ea
2 changed files with 11 additions and 3 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ from __future__ import annotations
from mcp.server.mcpserver import Context, MCPServer
from . import notify
from . import notify as push
from .mcp_run import erwartet, starten
server = MCPServer("notify", instructions=(
@@ -28,7 +28,7 @@ def _nutzer_id(ctx: Context | None) -> str | None:
@erwartet
def notify_setup(ctx: Context | None = None) -> dict:
"""Wie die Person Push-Nachrichten aufs Handy bekommt: persönlicher Kanal und Anleitung für die ntfy-App."""
return notify.einrichtung(_nutzer_id(ctx))
return push.einrichtung(_nutzer_id(ctx))
@server.tool()
@@ -36,7 +36,7 @@ def notify_setup(ctx: Context | None = None) -> dict:
def notify(message: str, title: str = "", priority: str = "default", ctx: Context | None = None) -> dict:
"""Kurze Push-Nachricht (max. 300 Zeichen) an die Person, die fragt. priority: min, low, default, high, urgent
(high/urgent nur bei Fristen in den nächsten Tagen). Keine Inhalte, Beträge oder Namen."""
return notify.senden(_nutzer_id(ctx), message, title, priority)
return push.senden(_nutzer_id(ctx), message, title, priority)
if __name__ == "__main__":
+8
View File
@@ -141,6 +141,14 @@ class Push(unittest.TestCase):
with self.assertRaises(ValueError):
notify.senden(U, "x", prioritaet="laut")
def test_server_werkzeuge_rufen_modul(self):
from butler import notify_server
ctx = mock.Mock(headers={"x-user-id": U})
self.assertEqual(notify_server.notify_setup(ctx=ctx)["kanal"], notify.kanal(U))
with mock.patch.object(notify, "senden", return_value={"gesendet": True}) as s:
notify_server.notify("Tagescheck: nichts Dringendes", priority="low", ctx=ctx)
s.assert_called_once_with(U, "Tagescheck: nichts Dringendes", "", "low")
if __name__ == "__main__":
unittest.main()