from __future__ import annotations import pathlib import pytest from PIL import Image from planemapper.renderer.airspace import draw_airspace from planemapper.renderer.overlay import draw_home_marker from planemapper.renderer.projection import MapBounds FIXTURE_DIR = pathlib.Path(__file__).parent / "fixtures" @pytest.fixture def white_image() -> Image.Image: return Image.new("RGB", (800, 480), color=(255, 255, 255)) @pytest.fixture def bounds() -> MapBounds: return MapBounds(home_lat=53.0, home_lon=-6.0, radius_nm=100.0) def test_home_marker_draws_red_cross(white_image: Image.Image, bounds: MapBounds) -> None: draw_home_marker(white_image, bounds) # Centre pixel should be red (COLOUR_HOME_MARKER) assert white_image.getpixel((400, 240)) == (255, 0, 0) def test_airspace_drawn_without_exception( white_image: Image.Image, bounds: MapBounds, monkeypatch: pytest.MonkeyPatch, ) -> None: monkeypatch.setattr( "planemapper.renderer.airspace.AIRSPACE_PATH", FIXTURE_DIR / "airspace_sample.geojson", ) draw_airspace(white_image, bounds) # should not raise def test_airspace_missing_file_no_exception( white_image: Image.Image, bounds: MapBounds, tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch, ) -> None: monkeypatch.setattr( "planemapper.renderer.airspace.AIRSPACE_PATH", tmp_path / "nonexistent.geojson", ) draw_airspace(white_image, bounds) # should not raise — logs WARNING instead