feat: stabilize multi-region runtime sync and worker orchestration

This commit is contained in:
root
2026-04-27 15:48:12 +08:00
parent 7cbde2aa78
commit 215a364891
137 changed files with 31931 additions and 1943 deletions

View 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()