Esempio n. 1
0
async def test_host_missing_fields(loop, lobby_server, player_service):
    player_id, session, proto = await connect_and_sign_in(
        ('test', 'test_password'), lobby_server)

    await read_until(proto, lambda msg: msg['command'] == 'game_info')

    with ClientTest(loop=loop, process_nat_packets=True,
                    proto=proto) as client:
        proto.send_message({
            'command':
            'game_host',
            'mod':
            '',
            'visibility':
            VisibilityState.to_string(VisibilityState.PUBLIC),
            'title':
            ''
        })
        await proto.drain()

        msg = await read_until(proto,
                               lambda msg: msg['command'] == 'game_info')

        assert msg['title'] == 'test's game'
        assert msg['mapname'] == 'scmp_007'
        assert msg['map_file_path'] == 'maps/scmp_007.zip'
        assert msg['featured_mod'] == 'faf'
def test_game_info_invalid():
    return {
        'title': 'Title with non ASCI char \xc3',
        'visibility': VisibilityState.to_string(VisibilityState.PUBLIC),
        'mod': 'faf',
        'mapname': 'scmp_007',
        'password': None,
        'lobby_rating': 1,
        'options': []
    }
def test_game_info():
    return {
        'title': 'Test game',
        'visibility': VisibilityState.to_string(VisibilityState.PUBLIC),
        'mod': 'faf',
        'mapname': 'scmp_007',
        'password': None,
        'lobby_rating': 1,
        'options': []
    }
Esempio n. 4
0
def test_game_info_invalid():
    return {
        'title': 'Title with non ASCI char \xc3',
        'gameport': '8000',
        'visibility': VisibilityState.to_string(VisibilityState.PUBLIC),
        'mod': 'faf',
        'mapname': 'scmp_007',
        'password': None,
        'lobby_rating': 1,
        'options': []
    }
Esempio n. 5
0
async def test_public_host(loop, lobby_server, player_service):
    player_id, session, proto = await connect_and_sign_in(("Dostya", "vodka"), lobby_server)

    proto.send_message(
        dict(command="game_host", mod="faf", visibility=VisibilityState.to_string(VisibilityState.PUBLIC))
    )
    await proto.drain()

    with TestClient(loop=loop, process_nat_packets=True, proto=proto) as client:
        await client.listen_udp()
        client.send_GameState(["Idle"])
        client.send_GameState(["Lobby"])
        await client._proto.writer.drain()
Esempio n. 6
0
async def test_public_host(loop, lobby_server, player_service):
    player_id, session, proto = await connect_and_sign_in(('test', 'test_password'),
                                                          lobby_server)

    proto.send_message(dict(command='game_host',
                            mod='faf',
                            visibility=VisibilityState.to_string(VisibilityState.PUBLIC)))
    await proto.drain()

    with TestClient(loop=loop, process_nat_packets=True, proto=proto) as client:
        await client.listen_udp()
        client.send_GameState(['Idle'])
        client.send_GameState(['Lobby'])
        await client._proto.writer.drain()
Esempio n. 7
0
async def test_public_host(loop, lobby_server, player_service):
    player_id, session, proto = await connect_and_sign_in(('Dostya', 'vodka'),
                                                           lobby_server)

    proto.send_message(dict(command='game_host',
                         mod='faf',
                         visibility=VisibilityState.to_string(VisibilityState.PUBLIC)))
    await proto.drain()

    with TestClient(loop=loop, process_nat_packets=True, proto=proto) as client:
        await client.listen_udp()
        client.send_GameState(['Idle'])
        client.send_GameState(['Lobby'])
        await client._proto.writer.drain()
Esempio n. 8
0
def test_command_game_host_creates_game(lobbyconnection, mock_games,
                                        test_game_info, players):
    lobbyconnection.player = players.hosting
    players.hosting.in_game = False
    lobbyconnection.protocol = mock.Mock()
    lobbyconnection.command_game_host(test_game_info)
    expected_call = {
        'game_mode': test_game_info['mod'],
        'name': test_game_info['title'],
        'host': players.hosting,
        'visibility': VisibilityState.to_string(VisibilityState.PUBLIC),
        'password': test_game_info['password'],
        'mapname': test_game_info['mapname'],
    }
    mock_games.create_game\
        .assert_called_with(**expected_call)
Esempio n. 9
0
def test_command_game_host_creates_game(lobbyconnection,
                                        mock_games,
                                        test_game_info,
                                        players):
    lobbyconnection.player = players.hosting
    players.hosting.in_game = False
    lobbyconnection.protocol = mock.Mock()
    lobbyconnection.command_game_host(test_game_info)
    expected_call = {
        'game_mode': test_game_info['mod'],
        'name': test_game_info['title'],
        'host': players.hosting,
        'visibility': VisibilityState.to_string(VisibilityState.PUBLIC),
        'password': test_game_info['password'],
        'mapname': test_game_info['mapname'],
    }
    mock_games.create_game\
        .assert_called_with(**expected_call)
Esempio n. 10
0
async def test_public_host(loop, lobby_server, player_service):
    # TODO: This test can't fail, why is it here?
    player_id, session, proto = await connect_and_sign_in(
        ('test', 'test_password'), lobby_server)

    await read_until(proto, lambda msg: msg['command'] == 'game_info')

    with ClientTest(loop=loop, process_nat_packets=True,
                    proto=proto) as client:
        proto.send_message({
            'command':
            'game_host',
            'mod':
            'faf',
            'visibility':
            VisibilityState.to_string(VisibilityState.PUBLIC)
        })
        await proto.drain()

        client.send_GameState(['Idle'])
        client.send_GameState(['Lobby'])
        await client._proto.writer.drain()