"""Batch agent result server name resolution."""

from server.application.server_batch_common import batch_server_display_name as _batch_server_display_name
from server.domain.models import Server


def test_batch_display_name_prefers_name():
    s = Server(id=164, name="武汉高琼棠商务科技有限公司", domain="1.2.3.4")
    assert _batch_server_display_name(s) == "武汉高琼棠商务科技有限公司"


def test_batch_display_name_falls_back_to_domain():
    s = Server(id=59, name="", domain="whgqt.com")
    assert _batch_server_display_name(s) == "whgqt.com"


def test_batch_display_name_missing_server():
    assert _batch_server_display_name(None) == "未知服务器"
