Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/test_daemon_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ async def _run():
assert args[0].endswith("python") or "python" in args[0]
assert args[1:] == ("-m", "emrg.server")

@patch("emrg.client.daemon_manager.asyncio.sleep", new_callable=AsyncMock)
@patch("emrg.client.daemon_manager.is_running", return_value=False)
@patch("emrg.client.daemon_manager.cleanup_server")
@patch("emrg.client.daemon_manager.asyncio.create_subprocess_exec",
new_callable=AsyncMock)
def test_raises_on_timeout(self, mock_spawn, mock_cleanup, mock_is_running):
def test_raises_on_timeout(self, mock_spawn, mock_cleanup, mock_is_running,
mock_sleep):
proc = MagicMock(pid=1234)
mock_spawn.return_value = proc

Expand Down Expand Up @@ -247,12 +249,14 @@ async def _run():
# _MAX_SPAWN_ATTEMPTS 次,超限抛节流错误;成功连接后归零。

class TestSpawnThrottle:
@patch("emrg.client.daemon_manager.asyncio.sleep", new_callable=AsyncMock)
@patch("emrg.client.daemon_manager.is_running", return_value=False)
@patch("emrg.client.daemon_manager.cleanup_server")
@patch("emrg.client.daemon_manager.asyncio.create_subprocess_exec",
new_callable=AsyncMock)
def test_start_daemon_throttles_after_max_attempts(self, mock_spawn,
mock_cleanup, mock_is_running):
mock_cleanup, mock_is_running,
mock_sleep):
proc = MagicMock(pid=1234)
mock_spawn.return_value = proc

Expand Down
Loading