mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-16 23:50:12 +01:00
document deck summary DFC badges, exporter annotations, and per-face metadata across README/DOCKER/release notes record completion of all MDFC roadmap follow-ups and add the authoring guide for multi-face CSV entries wire in optional DFC_PER_FACE_SNAPSHOT env support, exporter regression tests, and diagnostics updates noted in the changelog
80 lines
2.5 KiB
Python
80 lines
2.5 KiB
Python
from __future__ import annotations
|
|
|
|
import csv
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from code.deck_builder.phases.phase6_reporting import ReportingMixin
|
|
|
|
|
|
class DummyBuilder(ReportingMixin):
|
|
def __init__(self) -> None:
|
|
self.card_library = {
|
|
"Valakut Awakening // Valakut Stoneforge": {
|
|
"Card Type": "Instant",
|
|
"Count": 2,
|
|
"Mana Cost": "{2}{R}",
|
|
"Mana Value": "3",
|
|
"Role": "",
|
|
"Tags": [],
|
|
},
|
|
"Mountain": {
|
|
"Card Type": "Land",
|
|
"Count": 1,
|
|
"Mana Cost": "",
|
|
"Mana Value": "0",
|
|
"Role": "",
|
|
"Tags": [],
|
|
},
|
|
}
|
|
self.color_identity = ["R"]
|
|
self.output_func = lambda *_args, **_kwargs: None # silence export logs
|
|
self._full_cards_df = None
|
|
self._combined_cards_df = None
|
|
self.custom_export_base = "test_dfc_export"
|
|
|
|
|
|
@pytest.fixture()
|
|
def builder(monkeypatch: pytest.MonkeyPatch) -> DummyBuilder:
|
|
matrix = {
|
|
"Valakut Awakening // Valakut Stoneforge": {
|
|
"R": 1,
|
|
"_dfc_land": True,
|
|
"_dfc_counts_as_extra": True,
|
|
},
|
|
"Mountain": {"R": 1},
|
|
}
|
|
|
|
def _fake_compute(card_library, *_args, **_kwargs):
|
|
return matrix
|
|
|
|
monkeypatch.setattr(
|
|
"deck_builder.builder_utils.compute_color_source_matrix",
|
|
_fake_compute,
|
|
)
|
|
return DummyBuilder()
|
|
|
|
|
|
def test_export_decklist_csv_includes_dfc_note(tmp_path: Path, builder: DummyBuilder) -> None:
|
|
csv_path = Path(builder.export_decklist_csv(directory=str(tmp_path)))
|
|
with csv_path.open("r", encoding="utf-8", newline="") as handle:
|
|
reader = csv.DictReader(handle)
|
|
rows = {row["Name"]: row for row in reader}
|
|
|
|
valakut_row = rows["Valakut Awakening // Valakut Stoneforge"]
|
|
assert valakut_row["DFCNote"] == "MDFC: Adds extra land slot"
|
|
|
|
mountain_row = rows["Mountain"]
|
|
assert mountain_row["DFCNote"] == ""
|
|
|
|
|
|
def test_export_decklist_text_appends_dfc_annotation(tmp_path: Path, builder: DummyBuilder) -> None:
|
|
text_path = Path(builder.export_decklist_text(directory=str(tmp_path)))
|
|
lines = text_path.read_text(encoding="utf-8").splitlines()
|
|
|
|
valakut_line = next(line for line in lines if line.startswith("2 Valakut Awakening"))
|
|
assert "[MDFC: Adds extra land slot]" in valakut_line
|
|
|
|
mountain_line = next(line for line in lines if line.strip().endswith("Mountain"))
|
|
assert "MDFC" not in mountain_line
|