import unittest
from unittest.mock import patch

from amc_server.context import _resolve_zellij_bin


class ContextTests(unittest.TestCase):
    def test_resolve_zellij_bin_prefers_which(self):
        with patch("amc_server.context.shutil.which", return_value="/custom/bin/zellij"):
            self.assertEqual(_resolve_zellij_bin(), "/custom/bin/zellij")

    def test_resolve_zellij_bin_falls_back_to_default_name(self):
        with patch("amc_server.context.shutil.which", return_value=None), patch(
            "amc_server.context.Path.exists", return_value=False
        ), patch("amc_server.context.Path.is_file", return_value=False):
            self.assertEqual(_resolve_zellij_bin(), "zellij")


if __name__ == "__main__":
    unittest.main()
