f
This commit is contained in:
@@ -1,34 +1,37 @@
|
||||
import pytest
|
||||
from tarot.ui import CardDisplay
|
||||
from tarot.deck import Card
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tarot.deck import Card
|
||||
from tarot.ui import CardDisplay
|
||||
|
||||
|
||||
def test_card_display_delegation():
|
||||
"""Test that CardDisplay delegates to SpreadDisplay correctly."""
|
||||
with patch('tarot.ui.SpreadDisplay') as MockSpreadDisplay:
|
||||
with patch("tarot.ui.SpreadDisplay") as MockSpreadDisplay:
|
||||
# Mock HAS_PILLOW to True to ensure we proceed
|
||||
with patch('tarot.ui.HAS_PILLOW', True):
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user