"""Tests for HTTP client construction — esp. the request timeout that bounds LLM calls so a stalled endpoint can never hang a worker thread forever.""" from interns_mcp.client import make_client, _resolve_timeout, DEFAULT_REQUEST_TIMEOUT def test_default_timeout_is_bounded(): # A bare endpoint config must still get a finite, short-ish timeout — # the OpenAI SDK default (600s) is long enough to wedge the server. assert _resolve_timeout({}) == DEFAULT_REQUEST_TIMEOUT assert DEFAULT_REQUEST_TIMEOUT <= 120 def test_configured_timeout_overrides_default(): assert _resolve_timeout({"request_timeout": 42}) == 42.0 def test_client_is_built_with_timeout(): c = make_client({"base_url": "http://example.invalid", "request_timeout": 30}, "k") # OpenAI client exposes the configured timeout; must not be None. assert c.timeout is not None