"""Tests du graphique de présence annuelle des personnages."""

import matplotlib
from pathlib import Path

from lib.plots.minifig_characters import plot_character_year_presence


matplotlib.use("Agg")


def test_plot_character_year_presence(tmp_path: Path) -> None:
    """Génère la heatmap binaire personnage × année."""
    presence_path = tmp_path / "minifig_characters_year_presence.csv"
    destination = tmp_path / "figures" / "step22" / "minifig_characters_timeline.png"
    presence_path.write_text(
        "known_character,year,minifig_count\n"
        "Owen Grady,2020,2\n"
        "Owen Grady,2021,0\n"
        "Figurant,2020,3\n"
    )

    plot_character_year_presence(presence_path, destination)

    assert destination.exists()
    assert destination.stat().st_size > 0
