"""Tests para detect_distribution_type."""

import sys
import os

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

import numpy as np


def test_detect_too_few_samples():
    result = detect_distribution_type([1] * 5)
    assert result["type"] == "too_few_samples"


def test_detect_normal_ish():
    rng = np.random.default_rng(42)
    values = rng.normal(0, 1, 200).tolist()
    result = detect_distribution_type(values)
    assert result["type"] == "normal-ish", f"Got {result['type']}"


def test_detect_right_skewed():
    rng = np.random.default_rng(0)
    # Exponential distribution is heavily right-skewed
    values = rng.exponential(scale=1.0, size=200).tolist()
    result = detect_distribution_type(values)
    assert result["type"] in ("right-skewed", "lognormal-ish", "heavy-tail"), f"Got {result['type']}"


def test_detect_stats_keys():
    rng = np.random.default_rng(7)
    values = rng.normal(5, 2, 100).tolist()
    result = detect_distribution_type(values)
    assert "stats" in result
    assert "n" in result["stats"]
    assert result["stats"]["n"] == 100


def test_detect_exactly_30():
    rng = np.random.default_rng(1)
    values = rng.normal(0, 1, 30).tolist()
    result = detect_distribution_type(values)
    assert result["type"] != "too_few_samples"
