2c86ffd422
Implements altitude_to_colour() mapping altitude bands to the 6 e-ink palette colours, and classify_aircraft_type() resolving ADS-B category, callsign prefix, and altitude fallback to AircraftType enum. Adds 21 new tests (13 parametrised boundary cases + 8 icon classification); 89 tests total, all quality gates green. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
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)
|