Files
tarot/tests/test_card_display.py

41 lines
1.3 KiB
Python
Raw Normal View History

2026-02-11 00:02:35 -08:00
from unittest.mock import MagicMock, patch
2025-12-05 03:41:16 -08:00
import pytest
2026-02-11 00:02:35 -08:00
2025-12-05 03:41:16 -08:00
from tarot.deck import Card
2026-02-11 00:02:35 -08:00
from tarot.ui import CardDisplay
2025-12-05 03:41:16 -08:00
def test_card_display_delegation():
"""Test that CardDisplay delegates to SpreadDisplay correctly."""
2026-02-11 00:02:35 -08:00
with patch("tarot.ui.SpreadDisplay") as MockSpreadDisplay:
2025-12-05 03:41:16 -08:00
# Mock HAS_PILLOW to True to ensure we proceed
2026-02-11 00:02:35 -08:00
with patch("tarot.ui.HAS_PILLOW", True):
2025-12-05 03:41:16 -08:00
display = CardDisplay()
2026-02-11 00:02:35 -08:00
2025-12-05 03:41:16 -08:00
# Create dummy card
card = MagicMock(spec=Card)
card.name = "The Fool"
card.image_path = "fool.jpg"
cards = [card]
2026-02-11 00:02:35 -08:00
2025-12-05 03:41:16 -08:00
display.show_cards(cards, title="Test Spread")
2026-02-11 00:02:35 -08:00
2025-12-05 03:41:16 -08:00
# Verify SpreadDisplay was instantiated
assert MockSpreadDisplay.call_count == 1
2026-02-11 00:02:35 -08:00
2025-12-05 03:41:16 -08:00
# Verify run was called
MockSpreadDisplay.return_value.run.assert_called_once()
2026-02-11 00:02:35 -08:00
2025-12-05 03:41:16 -08:00
# Verify arguments passed to SpreadDisplay
args, _ = MockSpreadDisplay.call_args
reading = args[0]
deck_name = args[1]
2026-02-11 00:02:35 -08:00
2025-12-05 03:41:16 -08:00
assert deck_name == "default"
assert reading.spread.name == "Card List"
assert reading.spread.description == "Test Spread"
assert len(reading.drawn_cards) == 1
assert reading.drawn_cards[0].card == card
assert reading.drawn_cards[0].position.number == 1