"""Tests du graphique des minifigs par set."""

import matplotlib
from pathlib import Path

from lib.plots.minifig_counts import plot_minifigs_per_set


matplotlib.use("Agg")


def test_plot_minifigs_per_set_outputs_image(tmp_path: Path) -> None:
    """Génère l'image du nombre de minifigs par set."""
    counts_path = tmp_path / "minifig_counts_by_set.csv"
    destination_path = tmp_path / "figures" / "step20" / "minifigs_per_set.png"
    counts_path.write_text(
        "set_num,set_id,name,year,minifig_count\n"
        "123-1,123,Set A,2020,2\n"
        "124-1,124,Set B,2021,1\n"
    )

    plot_minifigs_per_set(counts_path, destination_path)

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