Exemple #1
0
def test_can_swap_cards():
    tab = Tableau()
    pos1 = (1,1)
    pos2 = (1,12)
    card1_before = tab.card_at(pos1)
    card2_before = tab.card_at(pos2)
    tab.swap(pos1, pos2)
    card1_after = tab.card_at(pos1)
    card2_after = tab.card_at(pos2)
    assert card1_after == card2_before
    assert card2_after == card1_before
Exemple #2
0
def test_can_swap_cards():
    tab = Tableau()
    pos1 = (1, 1)
    pos2 = (1, 12)
    card1_before = tab.card_at(pos1)
    card2_before = tab.card_at(pos2)
    tab.swap(pos1, pos2)
    card1_after = tab.card_at(pos1)
    card2_after = tab.card_at(pos2)
    assert card1_after == card2_before
    assert card2_after == card1_before
Exemple #3
0
def test_moveables_are_moveable():
    for i in range(1000):
        tab = Tableau()
        while not tab.has_moves():
            tab = Tableau()
        moveables = tab.find_moveable()
        for m in moveables:
            card = tab.card_at(m)
            if card.rank == Ranks.TWO:
                left_gaps = [gap for gap in tab.find_gaps() if gap[1] == 0]
                assert len(left_gaps) > 0
            else:
                target_card = Card(card.suit, Ranks.lower_rank(card.rank))
                assert target_card is not None
                target_loc = tab.find_card(target_card)
                assert tab.card_at((target_loc[0], target_loc[1]+1)) is None 
Exemple #4
0
def test_moveables_are_moveable():
    for i in range(1000):
        tab = Tableau()
        while not tab.has_moves():
            tab = Tableau()
        moveables = tab.find_moveable()
        for m in moveables:
            card = tab.card_at(m)
            if card.rank == Ranks.TWO:
                left_gaps = [gap for gap in tab.find_gaps() if gap[1] == 0]
                assert len(left_gaps) > 0
            else:
                target_card = Card(card.suit, Ranks.lower_rank(card.rank))
                assert target_card is not None
                target_loc = tab.find_card(target_card)
                assert tab.card_at((target_loc[0], target_loc[1] + 1)) is None
Exemple #5
0
def test_can_find_every_card():
    tab = Tableau()
    for row in range(len(tab.grid)):
        for col in range(len(tab.grid[row])):
            card = tab.card_at((row,col))
            if card is not None:
                loc = tab.find_card(card)
                assert loc[0] == row and loc[1] == col
Exemple #6
0
def test_can_find_every_card():
    tab = Tableau()
    for row in range(len(tab.grid)):
        for col in range(len(tab.grid[row])):
            card = tab.card_at((row, col))
            if card is not None:
                loc = tab.find_card(card)
                assert loc[0] == row and loc[1] == col