"""Tests du graphique global sur la part de têtes Yellow."""

import matplotlib
from pathlib import Path

from lib.plots.minifig_skin_tones import plot_yellow_share


matplotlib.use("Agg")


def test_plot_yellow_share(tmp_path: Path) -> None:
    """Génère un graphe de part Yellow sur le catalogue complet."""
    heads_path = tmp_path / "global_minifig_heads_by_year.csv"
    milestones_path = tmp_path / "milestones.csv"
    destination = tmp_path / "figures" / "step17" / "global_minifig_heads_yellow_share.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,FFFF00,false,Yellow,1\n"
    )
    milestones_path.write_text("year,description\n2020,Lancement\n")

    plot_yellow_share(heads_path, milestones_path, destination)

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