예제 #1
0
def lobbyconnection(
    event_loop,
    database,
    mock_protocol,
    mock_games,
    mock_players,
    mock_player,
    mock_geoip,
    mock_nts_client
):
    lc = LobbyConnection(
        database=database,
        geoip=mock_geoip,
        game_service=mock_games,
        players=mock_players,
        nts_client=mock_nts_client,
        ladder_service=asynctest.create_autospec(LadderService)
    )

    lc.player = mock_player
    lc.protocol = mock_protocol
    lc.player_service.fetch_player_data = CoroutineMock()
    lc.peer_address = Address("127.0.0.1", 1234)
    lc._authenticated = True
    return lc
예제 #2
0
async def test_command_avatar_select(mocker, db_engine,
                                     lobbyconnection: LobbyConnection,
                                     mock_player: Player):
    lobbyconnection.player = mock_player
    lobbyconnection.player.id = 2  # Dostya test user
    lobbyconnection._authenticated = True

    await lobbyconnection.on_message_received({
        'command':
        'avatar',
        'action':
        'select',
        'avatar':
        "http://content.faforever.com/faf/avatars/qai2.png"
    })

    async with db_engine.acquire() as conn:
        result = await conn.execute(
            "SELECT selected from avatars where idUser=2")
        row = await result.fetchone()
        assert row[0] == 1