async def test_handle_action_GameState_launching_calls_launch(
        game: Game, game_connection: GameConnection, players):
    game_connection.player = players.hosting
    game_connection.game = game
    game.launch = CoroutineMock()

    await game_connection.handle_action('GameState', ['Launching'])

    game.launch.assert_any_call()
async def test_handle_action_TeamkillReport_invalid_offender_id_and_name(
        game: Game, game_connection: GameConnection, database):
    game.launch = CoroutineMock()
    await game_connection.handle_action('TeamkillReport',
                                        ['270', 0, 'Dostya', 0, 'Geosearchef'])

    async with database.acquire() as conn:
        result = await conn.execute(
            "select game_id,id from moderation_report where reporter_id=2 and game_id=%s and game_incident_timecode=270",
            game.id)
        report = await result.fetchone()
        assert report is None
示例#3
0
async def test_handle_action_TeamkillReport_invalid_reporter_id_and_name(
        game: Game, game_connection: GameConnection, db_engine):
    game.launch = CoroMock()
    await game_connection.handle_action('TeamkillReport',
                                        ['250', 0, 'Askaholic', 0, 'Rhiza'])

    async with db_engine.acquire() as conn:
        result = await conn.execute(
            "select game_id,id from moderation_report where reporter_id=2 and game_id=%s and game_incident_timecode=250",
            game.id)
        report = await result.fetchone()
        assert report is None
async def test_handle_action_TeamkillHappened(game: Game,
                                              game_connection: GameConnection,
                                              database):
    game.launch = CoroutineMock()
    await game_connection.handle_action('TeamkillHappened',
                                        ['200', '2', 'Dostya', '3', 'Rhiza'])

    async with database.acquire() as conn:
        result = await conn.execute(
            "select game_id from teamkills where victim=2 and teamkiller=3 and game_id=%s and gametime=200",
            game.id)
        row = await result.fetchone()
        assert game.id == row[0]
示例#5
0
async def test_handle_action_TeamkillReport(game: Game,
                                            game_connection: GameConnection,
                                            database):
    game.launch = CoroutineMock()
    await game_connection.handle_action("TeamkillReport",
                                        ["200", "2", "Dostya", "3", "Rhiza"])

    async with database.acquire() as conn:
        result = await conn.execute(
            "select game_id,id from moderation_report where reporter_id=2 and game_id=%s and game_incident_timecode=200",
            game.id)
        report = await result.fetchone()
        assert report is None
async def test_handle_action_GameMods_post_launch_updates_played_cache(
        game: Game, game_connection: GameConnection, database):
    game.launch = CoroutineMock()
    game.remove_game_connection = CoroutineMock()

    await game_connection.handle_action(
        'GameMods', ['uids', 'foo bar EA040F8E-857A-4566-9879-0D37420A5B9D'])
    await game_connection.handle_action('GameState', ['Launching'])

    async with database.acquire() as conn:
        result = await conn.execute(
            "select `played` from table_mod where uid=%s",
            ('EA040F8E-857A-4566-9879-0D37420A5B9D', ))
        row = await result.fetchone()
        assert 2 == row[0]
async def test_handle_action_TeamkillReport_invalid_ids(
        game: Game, game_connection: GameConnection, database):
    game.launch = CoroutineMock()
    await game_connection.handle_action('TeamkillReport',
                                        ['230', 0, 'Dostya', 0, 'Rhiza'])

    async with database.acquire() as conn:
        result = await conn.execute(
            "select game_id,id from moderation_report where reporter_id=2 and game_id=%s and game_incident_timecode=230",
            game.id)
        report = await result.fetchone()
        assert game.id == report["game_id"]

        reported_user_query = await conn.execute(
            "select player_id from reported_user where report_id=%s",
            (report["id"]))
        data = await reported_user_query.fetchone()
        assert data["player_id"] == 3