def test_shoe_draw_should_return_first_card_and_remove_it_from_deck(self): shoe = blackjack.Shoe() shoe.cards = [blackjack.Card('club', 'an ace', 11), blackjack.Card('club', 'jack', 10)] first_card = shoe.draw() expect(first_card.figure == 'an ace' and first_card.color == 'club').to.be(True) expect(len(shoe.cards)).equal(1) expect(shoe.cards[0].figure == 'jack' and shoe.cards[0].color == 'club').to.be(True)
def test_shoe_create_one_packet_should_contains_uniq_card(self): shoe = blackjack.Shoe() shoe.create(1) visited_cards = [] for card in shoe.cards: already_in = next( (visited_card for visited_card in visited_cards if (visited_card.figure == card.figure and visited_card.color == card.color) ), None) expect(already_in).to.be(None) visited_cards.append(card)
def test_shoe_create_should_contains_correct_number_of_card(self): shoe = blackjack.Shoe() expect(len(shoe.cards)).equal(0) shoe.create(0) expect(len(shoe.cards)).equal(0) shoe.create(1) expect(len(shoe.cards)).equal(52) shoe.create(2) expect(len(shoe.cards)).equal(104)
def test_shoe_shuffle_should_contains_same_card_ordered_differently(self): shoe = blackjack.Shoe() shoe.create(1) ordered_cards = copy.deepcopy(shoe.cards) shoe.shuffle() different_position = 0 for index in range(0, len(shoe.cards)): if ordered_cards[index].figure != shoe.cards[index].figure or ordered_cards[index].color != shoe.cards[index].color: different_position += 1 expect(different_position).greater_than(0)
def test_empty_shoe_draw_should_return_none(self): shoe = blackjack.Shoe() card = shoe.draw() expect(card).to.be(None)