63 lines
2.1 KiB
Python
63 lines
2.1 KiB
Python
"""Tests du graphique minifigs par personnage."""
|
|
|
|
import matplotlib
|
|
from pathlib import Path
|
|
|
|
from lib.plots.minifig_characters import plot_minifigs_per_character
|
|
from lib.plots.minifig_characters import plot_new_characters_per_year
|
|
from lib.plots.minifig_characters import plot_character_variations_vs_total
|
|
|
|
|
|
matplotlib.use("Agg")
|
|
|
|
|
|
def test_plot_minifigs_per_character(tmp_path: Path) -> None:
|
|
"""Génère l'image de comptage par personnage."""
|
|
counts_path = tmp_path / "counts.csv"
|
|
destination = tmp_path / "figures" / "step22" / "minifig_characters.png"
|
|
counts_path.write_text(
|
|
"known_character,gender,minifig_count\n"
|
|
"Owen Grady,male,2\n"
|
|
"Figurant,unknown,1\n"
|
|
)
|
|
|
|
plot_minifigs_per_character(counts_path, destination)
|
|
|
|
assert destination.exists()
|
|
assert destination.stat().st_size > 0
|
|
|
|
|
|
def test_plot_character_variations_vs_total(tmp_path: Path) -> None:
|
|
"""Génère l'image comparant total et variations par personnage."""
|
|
counts_path = tmp_path / "variations.csv"
|
|
destination = tmp_path / "figures" / "step22" / "minifig_character_variations_totals.png"
|
|
counts_path.write_text(
|
|
"known_character,gender,variation_count,total_minifigs\n"
|
|
"Owen Grady,male,2,3\n"
|
|
"Ellie Sattler,female,1,2\n"
|
|
)
|
|
|
|
plot_character_variations_vs_total(counts_path, destination)
|
|
|
|
assert destination.exists()
|
|
assert destination.stat().st_size > 0
|
|
|
|
|
|
def test_plot_new_characters_per_year(tmp_path: Path) -> None:
|
|
"""Génère l'image du nombre de nouveaux personnages par an."""
|
|
counts_path = tmp_path / "new_characters.csv"
|
|
destination = tmp_path / "figures" / "step23" / "minifig_new_characters_per_year.png"
|
|
milestones_path = tmp_path / "milestones.csv"
|
|
counts_path.write_text(
|
|
"year,new_characters\n"
|
|
"2015,2\n"
|
|
"2016,0\n"
|
|
"2017,1\n"
|
|
)
|
|
milestones_path.write_text("year,description\n2016,Spin-off\n")
|
|
|
|
plot_new_characters_per_year(counts_path, milestones_path, destination, start_year=2015, end_year=2017)
|
|
|
|
assert destination.exists()
|
|
assert destination.stat().st_size > 0
|