from dobby.config import DobbyConfig


def test_default_config():
    config = DobbyConfig()
    assert config.port == 8420
    assert config.host == "127.0.0.1"
    assert config.max_concurrent_agents == 5
    assert config.default_timeout == 1800  # 30 min
    assert config.gpu_poll_interval == 300  # 5 min
    assert config.results_dir == "results"


def test_load_from_dict():
    config = DobbyConfig.from_dict({
        "port": 9000,
        "max_concurrent_agents": 10,
    })
    assert config.port == 9000
    assert config.max_concurrent_agents == 10
    assert config.host == "127.0.0.1"  # default preserved


def test_load_from_yaml(tmp_path):
    yaml_path = tmp_path / "dobby.yaml"
    yaml_path.write_text("port: 9000\nmax_concurrent_agents: 3\n")
    config = DobbyConfig.load(str(yaml_path))
    assert config.port == 9000
    assert config.max_concurrent_agents == 3


def test_load_missing_file_returns_defaults():
    config = DobbyConfig.load("/nonexistent/dobby.yaml")
    assert config.port == 8420
