"""Tests for get_segment_duration_bounds — Phase 1 of coverage-pass-planner-retry-fix."""

import logging
import sys
from pathlib import Path
from unittest.mock import patch

# Path setup so these tests can import recoil core modules
_RECOIL_ROOT = Path(__file__).resolve().parent.parent
if str(_RECOIL_ROOT) not in sys.path:
    sys.path.insert(0, str(_RECOIL_ROOT))

from recoil.core.model_profiles import get_segment_duration_bounds


def test_seeddance_bounds_returns_4_and_15():
    """seeddance-2.0 has min_duration_seconds=4 and max_duration_seconds=15."""
    result = get_segment_duration_bounds("seeddance-2.0")
    assert result == (4.0, 15.0)


def test_missing_min_logs_warning_and_defaults_to_4(caplog):
    """When min_duration_seconds is absent, warns and returns 4.0 as min."""
    from recoil.core import model_profiles
    model_profiles._warned_missing_min_duration.clear()
    fake_profile = {"max_duration_seconds": 10}
    with patch("recoil.core.model_profiles.get_profile", return_value=fake_profile):
        with caplog.at_level(logging.WARNING, logger="recoil.core.model_profiles"):
            result = get_segment_duration_bounds("some-model-without-min")
    assert result[0] == 4.0
    assert any("no min_duration_seconds" in r.message for r in caplog.records)


def test_returns_floats():
    """Both returned values must be exact float type."""
    result = get_segment_duration_bounds("seeddance-2.0")
    assert isinstance(result[0], float)
    assert isinstance(result[1], float)
