from __future__ import annotations

import pytest

from planemapper.constants import ALTITUDE_COLOURS
from planemapper.renderer.colours import altitude_to_colour


@pytest.mark.parametrize(
    "altitude_ft,expected",
    [
        (0, ALTITUDE_COLOURS[0]),  # surface → GREEN
        (1500, ALTITUDE_COLOURS[0]),  # boundary inclusive → GREEN
        (1501, ALTITUDE_COLOURS[1]),  # just above → BLUE
        (5000, ALTITUDE_COLOURS[1]),  # boundary inclusive → BLUE
        (5001, ALTITUDE_COLOURS[2]),  # just above → YELLOW
        (10000, ALTITUDE_COLOURS[2]),  # boundary inclusive → YELLOW
        (10001, ALTITUDE_COLOURS[3]),  # just above → RED
        (20000, ALTITUDE_COLOURS[3]),  # boundary inclusive → RED
        (20001, ALTITUDE_COLOURS[4]),  # just above → BLACK
        (35000, ALTITUDE_COLOURS[4]),  # boundary inclusive → BLACK
        (35001, ALTITUDE_COLOURS[5]),  # just above → WHITE
        (99999, ALTITUDE_COLOURS[5]),  # max band → WHITE
        (100000, ALTITUDE_COLOURS[5]),  # beyond max → WHITE (fallback)
    ],
)
def test_altitude_to_colour(altitude_ft: int, expected: tuple[int, int, int]) -> None:
    assert altitude_to_colour(altitude_ft) == expected


def test_all_six_colours_reachable() -> None:
    results = {altitude_to_colour(alt) for alt in [0, 2000, 7500, 15000, 25000, 40000]}
    assert results == set(ALTITUDE_COLOURS)
