"""Unit tests for the LLM capability table.""" import pytest from tradingagents.llm_clients.capabilities import ( ModelCapabilities, get_capabilities, ) @pytest.mark.unit class TestExactIdMatches: def test_deepseek_chat_supports_tool_choice(self): caps = get_capabilities("deepseek-chat") assert caps.supports_tool_choice is True def test_deepseek_reasoner_rejects_tool_choice(self): caps = get_capabilities("deepseek-reasoner") assert caps.supports_tool_choice is False assert caps.requires_reasoning_content_roundtrip is True def test_deepseek_v4_flash_rejects_tool_choice(self): caps = get_capabilities("deepseek-v4-flash") assert caps.supports_tool_choice is False assert caps.requires_reasoning_content_roundtrip is True def test_deepseek_v4_pro_rejects_tool_choice(self): caps = get_capabilities("deepseek-v4-pro") assert caps.supports_tool_choice is False assert caps.requires_reasoning_content_roundtrip is True @pytest.mark.unit class TestPatternMatches: """Forward-compat regex patterns catch unknown DeepSeek variants.""" def test_future_deepseek_v5_inherits_thinking_quirks(self): caps = get_capabilities("deepseek-v5-flash") assert caps.supports_tool_choice is False assert caps.requires_reasoning_content_roundtrip is True def test_future_deepseek_v9_inherits_thinking_quirks(self): caps = get_capabilities("deepseek-v9-anything") assert caps.supports_tool_choice is False def test_reasoner_variant_inherits_thinking_quirks(self): caps = get_capabilities("deepseek-reasoner-pro") assert caps.supports_tool_choice is False @pytest.mark.unit class TestDefault: """Unknown / non-DeepSeek models get the permissive default.""" def test_gpt_default(self): caps = get_capabilities("gpt-4.1") assert caps.supports_tool_choice is True assert caps.preferred_structured_method == "function_calling" def test_grok_default(self): caps = get_capabilities("grok-4-0709") assert caps.supports_tool_choice is True def test_unknown_model_default(self): caps = get_capabilities("totally-made-up-model-id") assert caps.supports_tool_choice is True def test_exact_match_precedes_pattern(self): """deepseek-chat must NOT match the v\\d regex.""" caps = get_capabilities("deepseek-chat") assert caps.supports_tool_choice is True @pytest.mark.unit def test_capabilities_dataclass_is_frozen(): """Capability rows are immutable so they can be safely shared.""" caps = get_capabilities("deepseek-chat") with pytest.raises(Exception): caps.supports_tool_choice = False # type: ignore[misc]