"""Test configuration management."""

from jankins.config import JankinsConfig


def test_config_from_values():
    """Test creating config from values."""
    config = JankinsConfig(
        JENKINS_URL="https://jenkins.example.com",
        JENKINS_USER="myuser",
        JENKINS_API_TOKEN="mytoken",
    )

    assert config.jenkins_url == "https://jenkins.example.com"
    assert config.jenkins_user == "myuser"
    assert config.jenkins_api_token == "mytoken"
    assert config.mcp_transport == "stdio"  # Default
    assert config.mcp_bind == "127.0.0.1:8080"  # Default


def test_config_bind_parsing():
    """Test bind address parsing."""
    config = JankinsConfig(
        JENKINS_URL="http://localhost",
        JENKINS_USER="user",
        JENKINS_API_TOKEN="token",
        MCP_BIND="0.0.0.0:9000",
    )

    assert config.bind_host == "0.0.0.0"
    assert config.bind_port == 9000


def test_config_defaults():
    """Test default configuration values."""
    config = JankinsConfig(
        JENKINS_URL="http://localhost",
        JENKINS_USER="user",
        JENKINS_API_TOKEN="token",
    )

    assert config.log_level == "INFO"
    assert config.log_json is False
    assert config.log_max_lines_default == 2000
    assert config.log_max_bytes_default == 262144
    assert config.jenkins_timeout == 30
    assert config.origin_enforce is False
