from __future__ import annotations

import pathlib

import pytest
from PIL import Image

from planemapper.display import NullDisplay
from planemapper.fetcher import FileFixtureFetcher
from planemapper.renderer.projection import MapBounds
from planemapper.renderer.renderer import Renderer

FIXTURE_DIR = pathlib.Path(__file__).parent / "fixtures"


def test_full_pipeline_smoke(monkeypatch: pytest.MonkeyPatch) -> None:
    monkeypatch.setattr(
        "planemapper.renderer.airspace.AIRSPACE_PATH",
        FIXTURE_DIR / "airspace_sample.geojson",
    )
    base_map = Image.new("RGB", (800, 480), color=(255, 255, 255))
    bounds = MapBounds(home_lat=53.0, home_lon=-6.0, radius_nm=100.0)
    fetcher = FileFixtureFetcher(FIXTURE_DIR / "aircraft_sample.json")
    renderer = Renderer(base_map, bounds)
    display = NullDisplay()

    aircraft_list = fetcher.fetch()
    result = renderer.render(aircraft_list)

    assert isinstance(result, Image.Image)
    assert result.size == (800, 480)
    display.show(result)  # should not raise
