def test_deck_order(self): deck = solution.CardCollection() card1, card2, card3 = random_cards(3) deck.add(card1), deck.add(card2), deck.add(card3) self.assertEqual(deck.top_card(), card3) self.assertEqual(deck.bottom_card(), card1) self.assertEqual(deck[1], card2)
def test_deck_index(self): deck = solution.CardCollection() card1, card2, card3 = random_cards(3) deck.add(card1) deck.add(card2) self.assertEqual(0, deck.index(card1)) self.assertEqual(1, deck.index(card2)) self.assertRaises(ValueError, lambda: deck.index(card3))
def test_deck_add(self): deck = solution.CardCollection() card1, card2 = random_cards(2) deck.add(card1) self.assertEqual(deck[0], card1) deck.add(card2) self.assertEqual(deck[1], card2) self.assertEqual(len(deck), 2)
def test_deck_draw(self): deck = solution.CardCollection(self.deck) card = deck.top_card() self.assertEqual(card, deck.draw_from_top()) self.assertEqual(len(deck), 51) card = deck.bottom_card() self.assertEqual(card, deck.draw_from_bottom()) self.assertEqual(len(deck), 50) i = random.randint(0, 49) card = deck[i] self.assertEqual(card, deck.draw(i)) self.assertEqual(len(deck), 49)
def test_deck_iteration(self): deck = solution.CardCollection(self.deck) for card in deck: self.assertIsInstance(card, solution.Card)
def test_standard_deck(self): deck = solution.CardCollection(self.deck) self.assertEqual(len(deck), 52)