class TestDealer(unittest.TestCase): def setUp(self): self.dealer = Dealer(cash_balance=100) def tearDown(self): del self.dealer def test_dealer_match_bet_negative_value(self): self.assertEqual( self.dealer.match_bet(-50), 50, 'Match bet methods accepts negative value. Check if absolute value implemented or if try catch statement present.' ) def test_dealer_match_bet_ten_dollar(self): self.assertEqual(self.dealer.match_bet(10), 10, 'Match bet is not matching bets correctly.') def test_dealer_match_bet_bigger_than_cash_balance_value(self): self.assertRaises(SystemExit, self.dealer.match_bet, 110) def test_dealer_match_bet_bigger_than_cash_balance_in_absolute_value(self): self.assertRaises(SystemExit, self.dealer.match_bet, -110) def test_dealer_match_bet_cash_balance_negative_value(self): self.dealer.match_bet(-10) self.assertEqual( self.dealer.cash_balance, 90, 'Cash balance not being substracted while allocating bets.') def test_dealer_match_bet_cash_balance_positive_value(self): self.dealer.match_bet(10) self.assertEqual( self.dealer.cash_balance, 90, 'Cash balance not being substracted while allocating bets.') def test_dealer_match_bet_cash_balance_equivalent_value(self): self.dealer.match_bet(100) self.assertEqual( self.dealer.cash_balance, 0, 'Match bet is not set to to accept bet equal to the cash balance. Check method implementation.' ) def test_dealer_is_soft_17_true_card_values_less_than_seventeen_and_two_cards( self): self.dealer.hand.add_card( [Card('Spades', 'Jack'), Card('Diamonds', 'Five')]) self.assertTrue(self.dealer.is_soft_17(), 'Is soft 17 no detecting soft 17.') def test_dealer_is_soft_17_true_card_values_less_than_seventeen_and_three_cards( self): self.dealer.hand.add_card([ Card('Spades', 'Four'), Card('Diamonds', 'Five'), Card('Hearts', 'Two') ]) self.assertTrue(self.dealer.is_soft_17(), 'Is soft 17 no detecting soft 17.') def test_dealer_is_soft_17_false_card_values_less_than_seventeen_and_four_cards( self): self.dealer.hand.add_card([ Card('Spades', 'Four'), Card('Diamonds', 'Five'), Card('Hearts', 'Two'), Card('Clubs', 'Three') ]) self.assertFalse(self.dealer.is_soft_17(), 'Is soft 17 no detecting soft 17.') def test_dealer_is_soft_17_false_seventeen_exactly(self): self.dealer.hand.add_card( [Card('Spades', 'Jack'), Card('Diamonds', 'Seven')]) self.assertFalse(self.dealer.is_soft_17(), 'Is soft 17 no detecting soft 17.') def test_dealer_is_soft_17_false_superior_to_seventeen(self): self.dealer.hand.add_card( [Card('Spades', 'Jack'), Card('Diamonds', 'Queen')]) self.assertFalse(self.dealer.is_soft_17(), 'Is soft 17 no detecting soft 17.') def test_dealer_return_card_to_deck_multiple_cards(self): self.dealer.hand.add_card(self.dealer.deck.deal_two_cards()) self.dealer.return_cards_to_deck(self.dealer.hand.hand) self.assertEqual(len(self.dealer.deck), 52, 'Return card to deck not working.') def test_dealer_return_card_to_deck_one_card(self): self.dealer.hand.add_card(self.dealer.deck.deal_one_card()) self.dealer.return_cards_to_deck(self.dealer.hand.hand) self.assertEqual(len(self.dealer.deck), 52, 'Return card to deck not working.') def test_dealer_add_cash_to_balance_negative(self): self.dealer.add_to_cash_balance(-10) self.assertEqual(self.dealer.cash_balance, 110, 'Add cash to balance not working properly.') def test_dealer_add_cash_to_balance_positive(self): self.dealer.add_to_cash_balance(10) self.assertEqual(self.dealer.cash_balance, 110, 'Add cash to balance not working properly.') def test_dealer_add_cash_to_balance_zero(self): self.dealer.add_to_cash_balance(0) self.assertEqual(self.dealer.cash_balance, 100, 'Add cash to balance not working properly.')