import pytest

from tarot.tarot_api import Tarot
from tarot.ui import CubeDisplay


def test_cube_display_init():
    cube = Tarot.cube
    display = CubeDisplay(cube, "default")
    assert display.current_wall_name == "North"
    assert display.deck_name == "default"


def test_cube_navigation():
    cube = Tarot.cube
    display = CubeDisplay(cube)

    # North -> Right -> East
    display._navigate("Right")
    assert display.current_wall_name == "East"

    # East -> Up -> Above
    display._navigate("Up")
    assert display.current_wall_name == "Above"

    # Above -> Down -> North
    display._navigate("Down")
    assert display.current_wall_name == "North"

    # North -> Left -> West
    display._navigate("Left")
    assert display.current_wall_name == "West"


def test_find_card_for_direction():
    cube = Tarot.cube
    display = CubeDisplay(cube)

    # North Wall, Center Direction -> Aleph -> The Fool
    wall = cube.wall("North")
    direction = wall.direction("Center")  # Should be Aleph?
    # Wait, let's check what Center of North is.
    # Actually, let's just mock a direction

    from kaballah.cube.attributes import WallDirection

    # Aleph -> The Fool
    d = WallDirection("Center", "Aleph")
    card = display._find_card_for_direction(d)
    assert card is not None
    assert "Fool" in card.name
