def test_register_new_players_game_bid(app, patch_geventws): # pylint: disable=unused-argument """ GIVEN a Flask application configured for testing WHEN the register_new_player function is called THEN check that the response is successful """ game_id, round_id, team_ids, player_ids = test_utils.setup_complete_game(4) ws_mess = WSM() ws_mess.client_sockets.clear() ws_mess.game_update = game.update ws_mess.update_refreshed_page_bid = MagicMock() ws_mess.update_refreshed_page_reveal = MagicMock() ws_mess.update_refreshed_page_trump = MagicMock() dummy_ws = geventwebsocket.websocket.WebSocket(None, None, None) play_pinochle.start(round_id) test_utils.set_game_state(game_id, 1) assert utils.query_game(game_id).state == 1 ws_mess.register_new_player(game_id, player_ids[0], dummy_ws) ws_mess.register_new_player(game_id, player_ids[1], dummy_ws) ws_mess.update_refreshed_page_bid.assert_called_with( round_id, player_ids[1], dummy_ws) ws_mess.update_refreshed_page_reveal.assert_not_called() ws_mess.update_refreshed_page_trump.assert_not_called()
def test_player_bid_submission(app, patch_geventws): """ GIVEN a Flask application configured for testing WHEN the '/api/round/{round_id}/kitty' page is requested (GET) THEN check that the response contains the expected information """ game_id, round_id, team_ids, player_ids = test_utils.setup_complete_game(4) # Set all to bidding play_pinochle.set_players_bidding(player_ids) # Submit a bid play_pinochle.submit_bid(round_id, choice(player_ids), 21) player_list = play_pinochle.players_still_bidding(round_id) assert len(player_list) == 4 # One player passes play_pinochle.submit_bid(round_id, choice(player_list), -1) player_list = play_pinochle.players_still_bidding(round_id) assert len(player_list) == 3 # Another player passes play_pinochle.submit_bid(round_id, choice(player_list), -1) player_list = play_pinochle.players_still_bidding(round_id) assert len(player_list) == 2 # Last player passes play_pinochle.submit_bid(round_id, choice(player_list), -1) player_list = play_pinochle.players_still_bidding(round_id) assert len(player_list) == 1 a_game = utils.query_game(game_id) a_round = utils.query_round(round_id) assert a_game.state == 1 assert a_round.bid == 21 assert str(a_round.bid_winner) == player_list[0]
def test_register_four_players(app, patch_geventws): # pylint: disable=unused-argument """ GIVEN a Flask application configured for testing WHEN the register_new_player function is called THEN check that the response is successful """ game_id, round_id, team_ids, player_ids = test_utils.setup_complete_game(4) ws_mess = WSM() ws_mess.client_sockets.clear() ws_mess.game_update = game.update dummy_ws = geventwebsocket.websocket.WebSocket(None, None, None) assert utils.query_game(game_id).state == 0 for player_id in player_ids: ws_mess.register_new_player(game_id, player_id, dummy_ws) assert utils.query_game(game_id).state == 1