def test_give_to_pool(self): """Give money from player.money to table.pool""" # Arrange us1 = User(username='******') us1.save() player1 = Player(name=us1, money=50) player1.save() table = Table(player1=player1, pool=0) # Act table.give_to_pool(player1, 10) # Assertion self.assertEqual(table.pool, 10) self.assertEqual(player1.money, 40)
def test_make_turn(self): """That function is call in every game page overload""" # Arrange us1 = User(username='******') us1.save() us2 = User(username='******') us2.save() us3 = User(username='******') us3.save() us4 = User(username='******') us4.save() player1 = Player(name=us1, state='check', money=90) player1.save() player2 = Player(name=us2, state='check', money=90) player2.save() player3 = Player(name=us3, state='check', money=90) player3.save() player4 = Player(name=us4, state='check', money=90) player4.save() table = Table(player1=player1, player2=player2, player3=player3, player4=player4, game_state='ready') # Acts & Assertions table.start() table.dealer_button() self.assertEqual(table.game_state, 'dealer') table.take_small_blind() self.assertEqual(table.game_state, 'small_blind') table.take_big_blind() self.assertEqual(table.game_state, 'big_blind') # All players must give to the pool the same value table.give_to_pool(player1, 2) table.give_to_pool(player2, 1) table.give_to_pool(player4, 2) table.fill_deck_by_all_cards() table.set_all_in_game_players_state('check') table.make_turn() self.assertEqual(table.game_state, 'give_2') self.assertEqual(player1.state, 'start') self.assertEqual(player2.state, 'start') self.assertEqual(player3.state, 'start') self.assertEqual(player4.state, 'start') table.set_all_in_game_players_state('check') table.make_turn() self.assertEqual(table.game_state, 'give_3') self.assertEqual(player1.state, 'start') self.assertEqual(player2.state, 'start') self.assertEqual(player3.state, 'start') self.assertEqual(player4.state, 'start') table.set_all_in_game_players_state('check') table.player1.state = 'pass' table.make_turn() self.assertEqual(table.game_state, 'give_1') self.assertEqual(player1.state, 'pass') self.assertEqual(player2.state, 'start') self.assertEqual(player3.state, 'start') self.assertEqual(player4.state, 'start') table.set_all_in_game_players_state('check') table.make_turn() self.assertEqual(table.game_state, 'give_1_again') self.assertEqual(player1.state, 'pass') self.assertEqual(player2.state, 'start') self.assertEqual(player3.state, 'start') self.assertEqual(player4.state, 'start') table.set_all_in_game_players_state('check') table.player2.state = 'pass' table.make_turn() self.assertEqual(table.game_state, 'winner') self.assertEqual(player1.state, 'pass') self.assertEqual(player2.state, 'pass') self.assertEqual(player3.state, 'start') self.assertEqual(player4.state, 'start') table.set_all_in_game_players_state('check') table.make_turn() self.assertEqual(table.game_state, 'ready') self.assertEqual(player1.state, 'start') self.assertEqual(player2.state, 'start') self.assertEqual(player3.state, 'start') self.assertEqual(player4.state, 'start') table.set_all_in_game_players_state('check') table.make_turn() self.assertEqual(table.game_state, 'small_blind') self.assertEqual(player1.state, 'start') self.assertEqual(player2.state, 'start') self.assertEqual(player3.state, 'start') self.assertEqual(player4.state, 'start') table.set_all_in_game_players_state('check') table.make_turn() self.assertEqual(table.game_state, 'big_blind') self.assertEqual(player1.state, 'start') self.assertEqual(player2.state, 'start') self.assertEqual(player3.state, 'start') self.assertEqual(player4.state, 'start')