from __future__ import annotations

import pytest
from PIL import Image

from planemapper.renderer import basemap


def test_load_returns_image(tmp_path, monkeypatch):
    img_path = tmp_path / "background.png"
    img = Image.new("RGB", (800, 480), color=(255, 255, 255))
    img.save(img_path)
    monkeypatch.setattr("planemapper.renderer.basemap.BACKGROUND_PATH", img_path)
    result = basemap.load()
    assert result.size == (800, 480)


def test_load_raises_if_missing(tmp_path, monkeypatch):
    missing = tmp_path / "nonexistent.png"
    monkeypatch.setattr("planemapper.renderer.basemap.BACKGROUND_PATH", missing)
    with pytest.raises(FileNotFoundError):
        basemap.load()
