async def test_handle_action_GameState_lobby_calls_ConnectToPeer( game: Game, game_connection: GameConnection, event_loop, players): game_connection.send = CoroutineMock() game_connection.connect_to_host = CoroutineMock() game_connection.connect_to_peer = CoroutineMock() game_connection.player = players.joining players.joining.game = game game.host = players.hosting game.map_file_path = 'maps/some_map.zip' game.map_folder_name = 'some_map' peer_conn = mock.Mock() players.peer.game_connection = peer_conn game.connections = [peer_conn] await game_connection.handle_action('GameState', ['Lobby']) await exhaust_callbacks(event_loop) game_connection.connect_to_peer.assert_called_with(peer_conn)
async def test_handle_action_GameState_lobby_calls_ConnectToPeer( game: Game, game_connection: GameConnection, players): game_connection.send_message = mock.MagicMock() game_connection.connect_to_host = CoroMock() game_connection.connect_to_peer = CoroMock() game_connection.player = players.joining players.joining.game = game game.host = players.hosting game.map_file_path = 'maps/some_map.zip' game.map_folder_name = 'some_map' game.connections = [players.peer.game_connection] await game_connection.handle_action('GameState', ['Lobby']) # Give the connection coro time to run await asyncio.sleep(0.1) game_connection.connect_to_peer.assert_called_with( players.peer.game_connection)