"""Tests for markitect.llm.factory."""

import pytest

from markitect.llm.factory import create_adapter
from markitect.llm.openrouter import OpenRouterAdapter
from markitect.llm.claude_code import ClaudeCodeAdapter
from markitect.llm.exceptions import LLMConfigurationError


class TestCreateAdapter:
    def test_openrouter(self):
        adapter = create_adapter("openrouter", api_key="sk-test")
        assert isinstance(adapter, OpenRouterAdapter)

    def test_claude_code(self):
        adapter = create_adapter("claude-code")
        assert isinstance(adapter, ClaudeCodeAdapter)

    def test_unknown_provider(self):
        with pytest.raises(LLMConfigurationError) as exc_info:
            create_adapter("unknown-provider")
        assert "unknown-provider" in str(exc_info.value)

    def test_model_passed_through(self):
        adapter = create_adapter("claude-code", model="opus")
        assert adapter._model == "opus"

    def test_openrouter_system_prompt(self):
        adapter = create_adapter(
            "openrouter", api_key="sk-test", system_prompt="Be helpful"
        )
        assert adapter._system_prompt == "Be helpful"
