"""Tests for Baota SSH login helpers.""" from unittest.mock import AsyncMock, patch import pytest from server.domain.models import Server from server.infrastructure.btpanel.ssh_login import detect_bt_panel_installed @pytest.mark.asyncio async def test_detect_bt_panel_installed_uses_status_field(): server = Server(id=1, name="s", domain="1.2.3.4") with patch( "server.infrastructure.btpanel.ssh_login.exec_ssh_command", new_callable=AsyncMock, return_value={"status": "success", "stdout": "BT_OK\n", "stderr": "", "exit_code": 0}, ): assert await detect_bt_panel_installed(server) is True @pytest.mark.asyncio async def test_detect_bt_panel_installed_failed_ssh(): server = Server(id=1, name="s", domain="1.2.3.4") with patch( "server.infrastructure.btpanel.ssh_login.exec_ssh_command", new_callable=AsyncMock, return_value={"status": "connection_error", "stdout": "", "stderr": "refused", "exit_code": -1}, ): assert await detect_bt_panel_installed(server) is False