"""Tests para summary_stats."""

import math
import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from summary_stats import summary_stats


def test_summary_stats_basic():
    result = summary_stats([1, 2, 3, 4, 5])
    assert result["n"] == 5
    assert abs(result["mean"] - 3.0) < 1e-9
    assert abs(result["median"] - 3.0) < 1e-9
    assert abs(result["p25"] - 2.0) < 0.01
    assert abs(result["p75"] - 4.0) < 0.01


def test_summary_stats_empty():
    result = summary_stats([])
    assert result["n"] == 0
    assert math.isnan(result["mean"])
    assert math.isnan(result["median"])
    assert math.isnan(result["p25"])
    assert math.isnan(result["p75"])


def test_summary_stats_single():
    result = summary_stats([7.0])
    assert result["n"] == 1
    assert abs(result["mean"] - 7.0) < 1e-9
    assert abs(result["median"] - 7.0) < 1e-9


def test_summary_stats_keys():
    result = summary_stats([1, 2, 3])
    assert set(result.keys()) == {"n", "mean", "median", "p25", "p75"}
