def test_empty_hand(self): """ Tests the state of a newly initialized hand """ h = Hand() self.assertListEqual(list(h.get_possible_scores()), [0]) self.assertEqual(h.hands.root.val, 0) self.assertListEqual(list(h.get_cards()), [])
def test_add_card_one_not_ace(self): """ Tests the state of adding 1 non-ace card to the hand """ h = Hand() card = Card('king', [10]) h.add_card(card) self.assertListEqual(list(h.get_possible_scores()), [10]) self.assertListEqual(list(h.get_cards()), [card]) expected_tree = BinaryTree(BinaryTreeNode(0, BinaryTreeNode(10))) self.assertTrue(h.hands.is_equivalent(expected_tree))
def test_add_card_multiple_no_ace(self): """ Tests the state of adding multiple non-ace cards to the hand """ h = Hand() card1 = Card('two', [2]) card2 = Card('king', [10]) h.add_card(card1) h.add_card(card2) self.assertListEqual(list(h.get_possible_scores()), [12]) self.assertListEqual(list(h.get_cards()), [card1, card2]) expected_tree = BinaryTree( BinaryTreeNode(0, BinaryTreeNode(2, BinaryTreeNode(12)))) self.assertTrue(h.hands.is_equivalent(expected_tree))