"""Unit tests for exploration budget resolution (platform defaults + campaign override)."""

from agenteval.exploration.models import resolve_budget
from agenteval.models import Campaign


def _campaign(**overrides) -> Campaign:
    base = {
        "name": "c",
        "target_id": "t-1",
        "window_seconds": 86400,
        "plan": [{"scenario_id": "s-1", "offset_seconds": 0, "count": 1}],
    }
    base.update(overrides)
    return Campaign(**base)


def test_platform_defaults_when_no_override():
    budget = resolve_budget(_campaign())
    assert budget.max_sessions == 8
    assert budget.max_turns == 12
    assert budget.min_interval_seconds == 30 * 60


def test_partial_override_falls_back_to_defaults():
    campaign = _campaign(exploration_budget={"max_sessions": 3})
    budget = resolve_budget(campaign)
    assert budget.max_sessions == 3
    assert budget.max_turns == 12
    assert budget.min_interval_seconds == 30 * 60


def test_full_override():
    campaign = _campaign(
        exploration_budget={"max_sessions": 2, "max_turns": 5, "min_interval_seconds": 600}
    )
    budget = resolve_budget(campaign)
    assert (budget.max_sessions, budget.max_turns, budget.min_interval_seconds) == (2, 5, 600)
