def test_move_with_non_top_ace_throws_error(): game = Game(no_shuffle=True) game.deal() game.draw() game.draw() with assert_raises(ValueError): game.move_card('as')
def test_move_card_with_valid_move_of_ace_to_suit_pile(): game = Game(no_shuffle=True) game.deal() game.move_card('ac') assert_equal(1, len(game.piles[2])) assert_equal(5, len(game.piles[11])) card = game.piles[2][0] assert_true(card.is_face_up()) assert_equal(2, card.pile_number) assert_equal(0, card.pile_index)
def test_move_with_king_to_empty_table_pile(): game = Game(no_shuffle=True) card = game.cards[12] card.pile_number = 1 card.pile_index = 0 game.piles[1].add_card(card) game.move_card('ks') assert_equal(0, len(game.piles[1])) assert_equal(1, len(game.piles[6])) top_card = game.piles[6].top() assert_equal(card, top_card)
def test_move_invalid_card_suit_raises_error(): game = Game(no_shuffle=True) card_to_move = game.cards[0] card_to_move.pile_number = 1 card_to_move.pile_index = 0 game.piles[1].add_card(card_to_move) card_on_stack = game.cards[1] card_on_stack.pile_number = 6 card_on_stack.pile_index = 0 game.piles[6].add_card(card_on_stack) with assert_raises(ValueError): game.move_card('as', '2s')
def test_move_single_card(): game = Game(no_shuffle=True) card_to_move = game.cards[0] card_to_move.pile_number = 1 card_to_move.pile_index = 0 game.piles[1].add_card(card_to_move) card_on_stack = game.cards[14] card_on_stack.pile_number = 6 card_on_stack.pile_index = 0 game.piles[6].add_card(card_on_stack) game.move_card('as', '2h') assert_equal(0, len(game.piles[1])) assert_equal(2, len(game.piles[6]))
def test_move_stack(): game = Game(no_shuffle=True) card_to_move = game.cards[14] card_to_move.flip() card_to_move.pile_number = 7 card_to_move.pile_index = 0 game.piles[7].add_card(card_to_move) card_to_move = game.cards[0] card_to_move.flip() card_to_move.pile_number = 7 card_to_move.pile_index = 1 game.piles[7].add_card(card_to_move) card_on_stack = game.cards[2] card_to_move.flip() card_on_stack.pile_number = 6 card_on_stack.pile_index = 0 game.piles[6].add_card(card_on_stack) game.move_card('2h', '3s') assert_equal(0, len(game.piles[7])) assert_equal(3, len(game.piles[6]))
def test_move_with_only_non_ace_throws_error(): game = Game(no_shuffle=True) game.deal() with assert_raises(ValueError): game.move_card('6d')
def test_move_card_throws_error_for_non_facing_up_card(): game = Game(no_shuffle=True) game.deal() with assert_raises(ValueError): game.move_card('as')