"""Tests du graphique de corrélation pièces/minifigs."""

import matplotlib
from pathlib import Path

from lib.plots.minifig_parts_correlation import plot_minifig_parts_correlation


matplotlib.use("Agg")


def test_plot_minifig_parts_correlation(tmp_path: Path) -> None:
    """Génère le graphique comparatif pièces/minifigs."""
    correlation_path = tmp_path / "minifig_parts_correlation.csv"
    destination = tmp_path / "figures" / "step26" / "minifig_parts_correlation.png"
    correlation_path.write_text(
        "scope,set_num,num_parts,minifig_count\n"
        "filtered,123-1,300,2\n"
        "filtered,124-1,150,1\n"
        "catalog,123-1,300,2\n"
        "catalog,124-1,150,1\n"
        "catalog,200-1,100,3\n"
    )

    plot_minifig_parts_correlation(correlation_path, destination)

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