"""Tests des visualisations globales des têtes de minifigs."""

import matplotlib
from pathlib import Path

from lib.plots.global_minifig_heads import plot_global_head_shares


matplotlib.use("Agg")


def test_plot_global_head_shares(tmp_path: Path) -> None:
    """Génère un graphique de parts de couleur sur le catalogue complet."""
    heads_path = tmp_path / "global_minifig_heads_by_year.csv"
    destination = tmp_path / "figures" / "step17" / "global_minifig_heads_shares.png"
    heads_path.write_text(
        "year,color_rgb,is_translucent,color_name,quantity\n"
        "2020,FFFF00,false,Yellow,2\n"
        "2020,FFE1BD,false,Light Flesh,1\n"
        "2021,FFE1BD,false,Light Flesh,3\n"
        "2021,E7B68F,false,Medium Dark Flesh,1\n"
        "2021,FFFF00,false,Yellow,2\n"
    )

    plot_global_head_shares(heads_path, destination)

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