Adds comprehensive test coverage for the amc_server package: - test_context.py: Tests _resolve_zellij_bin preference order (which first, then fallback to bare name) - test_control.py: Tests SessionControlMixin including two-step Enter injection with configurable delay, freeform response handling, plugin inject with explicit session/pane targeting, and unsafe fallback behavior - test_state.py: Tests StateMixin zellij session parsing with the resolved binary path Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import subprocess
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
import amc_server.mixins.state as state_mod
|
|
from amc_server.mixins.state import StateMixin
|
|
|
|
|
|
class DummyStateHandler(StateMixin):
|
|
pass
|
|
|
|
|
|
class StateMixinTests(unittest.TestCase):
|
|
def test_get_active_zellij_sessions_uses_resolved_binary_and_parses_output(self):
|
|
handler = DummyStateHandler()
|
|
state_mod._zellij_cache["sessions"] = None
|
|
state_mod._zellij_cache["expires"] = 0
|
|
|
|
completed = subprocess.CompletedProcess(
|
|
args=[],
|
|
returncode=0,
|
|
stdout="infra [created 1h ago]\nwork\n",
|
|
stderr="",
|
|
)
|
|
|
|
with patch.object(state_mod, "ZELLIJ_BIN", "/opt/homebrew/bin/zellij"), patch(
|
|
"amc_server.mixins.state.subprocess.run", return_value=completed
|
|
) as run_mock:
|
|
sessions = handler._get_active_zellij_sessions()
|
|
|
|
self.assertEqual(sessions, {"infra", "work"})
|
|
args = run_mock.call_args.args[0]
|
|
self.assertEqual(args, ["/opt/homebrew/bin/zellij", "list-sessions", "--no-formatting"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|