def make_connection(player, connectivity): lc = LobbyConnection(loop) lc.protocol = mock.Mock() conn = GameConnection(loop=loop, lobby_connection=lc, player_service=player_service, games=game_service) conn.player = player conn.game = game conn._transport = transport conn._connectivity_state.set_result(connectivity) return conn
def game_connection(request, game, loop, player_service, players, game_service, transport): from server import GameConnection, LobbyConnection conn = GameConnection(loop=loop, lobby_connection=mock.create_autospec(LobbyConnection(loop)), player_service=player_service, games=game_service) conn._transport = transport conn.player = players.hosting conn.game = game conn.lobby = mock.Mock(spec=LobbyConnection) conn.finished_sim = False def fin(): conn.abort() request.addfinalizer(fin) return conn