Add process controls and restart command
This commit is contained in:
23
tests/test_restart_command.py
Normal file
23
tests/test_restart_command.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import signal
|
||||
import unittest
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from app.commands.builtins import restart
|
||||
|
||||
|
||||
class RestartCommandTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_restart_confirms_then_stops_current_process(self) -> None:
|
||||
ctx = type("Context", (), {"reply": AsyncMock()})()
|
||||
|
||||
with patch("app.commands.builtins.os.kill") as kill:
|
||||
await restart(ctx)
|
||||
|
||||
ctx.reply.assert_awaited_once_with("Stopping bot process for restart")
|
||||
kill.assert_called_once_with(os.getpid(), signal.SIGTERM)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user