"""Unit tests for Proposal.key() stability — int/float coercion and distinct-param separation."""
from __future__ import annotations

from fxhnt.application.factory.analysts import Proposal


def test_int_and_float_params_produce_same_key() -> None:
    """int 20 and float 20.0 must yield identical keys so the same hypothesis is not counted twice."""
    p_int = Proposal("ES", "trend", {"window": 20})
    p_float = Proposal("ES", "trend", {"window": 20.0})
    assert p_int.key() == p_float.key()


def test_large_int_and_float_produce_same_key() -> None:
    p_int = Proposal("ES", "trend", {"window": 100})
    p_float = Proposal("ES", "trend", {"window": 100.0})
    assert p_int.key() == p_float.key()


def test_different_params_produce_different_keys() -> None:
    """Two genuinely different parameter values must NOT collapse to the same key."""
    p1 = Proposal("ES", "trend", {"window": 20.0})
    p2 = Proposal("ES", "trend", {"window": 50.0})
    assert p1.key() != p2.key()


def test_different_kind_produces_different_key() -> None:
    p1 = Proposal("ES", "trend", {"window": 20.0})
    p2 = Proposal("ES", "momentum", {"window": 20.0})
    assert p1.key() != p2.key()


def test_different_market_produces_different_key() -> None:
    p1 = Proposal("ES", "trend", {"window": 20.0})
    p2 = Proposal("NQ", "trend", {"window": 20.0})
    assert p1.key() != p2.key()


def test_params_coerced_to_float_on_construction() -> None:
    """__post_init__ must coerce int values to float in the stored dict."""
    p = Proposal("ES", "trend", {"window": 100})
    assert isinstance(p.params["window"], float)
    assert p.params["window"] == 100.0
