feat: add bot restart functionality via API and Discord command

This commit is contained in:
mmacierzanka committed 2026-09-11 01:21:26 +02:00
1 parent 82746e4c83
commit 708e3591ed
7 files changed
+172 -5

No files matched your search

+14
View File
@@ -11,6 +11,7 @@ from zyrarbot.settings import Settings
EXPECTED_ENDPOINTS = {
("get", "/api/status"),
("get", "/api/health"),
("post", "/api/restart"),
("post", "/api/play"),
("post", "/api/play_file"),
("post", "/api/pause"),
@@ -71,6 +72,19 @@ class ApiSurfaceTest(unittest.TestCase):
self.assertTrue(self.spec["openapi"].startswith("3."))
self.assertIn("ŻyrarBOT", self.spec["info"]["title"])
def test_restart_endpoint_calls_restart_state(self):
import asyncio
from unittest.mock import MagicMock
from zyrarbot.ui.api.routers.status_router import restart_bot
mock_request = MagicMock()
mock_restart = MagicMock()
mock_request.app.state.restart = mock_restart
result = asyncio.run(restart_bot(mock_request))
self.assertEqual(result, {"status": "restarting"})
mock_restart.assert_called_once()
if __name__ == "__main__":
unittest.main()