feat: stabilize multi-region runtime sync and worker orchestration
This commit is contained in:
37
domain-api/tests/test_runtime_control_service.py
Normal file
37
domain-api/tests/test_runtime_control_service.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.services.runtime_control_service import runtime_action
|
||||
|
||||
|
||||
class RuntimeControlServiceTests(unittest.TestCase):
|
||||
@patch("app.services.runtime_control_service._emit_runtime_action_event")
|
||||
@patch("app.services.runtime_control_service.send_worker_command")
|
||||
def test_runtime_action_stop_detection_forwards_target_payload(
|
||||
self,
|
||||
mock_send_worker_command,
|
||||
_mock_emit_runtime_action_event,
|
||||
) -> None:
|
||||
mock_send_worker_command.return_value = (True, "已发送 Worker 控制指令")
|
||||
|
||||
ok, message, data = runtime_action(
|
||||
"stop_detection",
|
||||
payload={"target_node_codes": ["mainland-controller-01-a", "mainland-controller-01-b"]},
|
||||
)
|
||||
|
||||
self.assertTrue(ok)
|
||||
self.assertEqual("已发送 Worker 控制指令", message)
|
||||
mock_send_worker_command.assert_called_once_with(
|
||||
"stop_detection",
|
||||
payload={"target_node_codes": ["mainland-controller-01-a", "mainland-controller-01-b"]},
|
||||
)
|
||||
self.assertEqual(
|
||||
["mainland-controller-01-a", "mainland-controller-01-b"],
|
||||
data["payload"]["target_node_codes"],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user