"""Tests du graphique d'évolution minifigs/set."""

import matplotlib
from pathlib import Path

from lib.plots.minifig_parts_timeline import plot_minifigs_per_set_timeline


matplotlib.use("Agg")


def test_plot_minifigs_per_set_timeline(tmp_path: Path) -> None:
    """Génère la courbe minifigs/set."""
    timeline_path = tmp_path / "minifigs_per_set_timeline.csv"
    destination = tmp_path / "figures" / "step26" / "minifigs_per_set_timeline.png"
    timeline_path.write_text(
        "scope,year,average_minifigs_per_set,set_count\n"
        "filtered,2020,1.500,2\n"
        "filtered,2021,2.000,1\n"
        "catalog,2020,1.000,3\n"
        "catalog,2021,2.500,2\n"
    )

    plot_minifigs_per_set_timeline(timeline_path, destination)

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