Files
tarot/tests/test_card_display.py

38 lines
1.4 KiB
Python
Raw Normal View History

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