def test_handle_round_end_winning_streak_triggers_teams_callback_already_called_multiple_times( self): mocked_balance_plugin = mock() mocked_balance_plugin.callback_teams = lambda: None Plugin._loaded_plugins["balance"] = mocked_balance_plugin # pylint: disable=protected-access setup_game_in_progress(game_type="ca", roundlimit=8, red_score=4, blue_score=3) red_player1 = fake_player(123, "Red Player1", "red") red_player2 = fake_player(456, "Red Player2", "red") blue_player1 = fake_player(246, "Blue Player1", "blue") blue_player2 = fake_player(975, "Blue Player2", "blue") connected_players(red_player1, red_player2, fake_player(42, "Spec Player", "spectator"), blue_player1, blue_player2) self.plugin.winning_teams = [ "blue", "blue", "blue", "red", "red", "red", "red" ] undecorated(self.plugin.handle_round_end)(self.plugin, { "TEAM_WON": "RED" }) players = { p.steam_id: "ca" for p in [red_player1, red_player2, blue_player1, blue_player2] } verify(mocked_balance_plugin, times=0).add_request(players, mocked_balance_plugin.callback_teams, minqlx.CHAT_CHANNEL)
def setUp(self): setup_plugin() setup_cvars({ "qlx_balanceUseLocal": "0", }) setup_game_in_progress() connected_players() self.plugin = balance()
def test_handle_round_end_wrong_gametype(self): setup_game_in_progress(game_type="rr") return_code = undecorated(self.plugin.handle_round_end)( self.plugin, { "TEAM_WON": "RED" }) assert_that(return_code, is_(minqlx.RET_NONE))
def test_handle_round_end_suggestion_threshold_not_met(self): setup_game_in_progress(roundlimit=8, red_score=4, blue_score=3) return_code = undecorated(self.plugin.handle_round_end)( self.plugin, { "TEAM_WON": "RED" }) assert_that(return_code, is_(minqlx.RET_NONE))
def test_plays_sound_when_round_still_running(self): warner_thread_name = "test_plays_sound_when_round_still_running1" setup_game_in_progress(game_type="ca") self.warner.warner_thread_name = warner_thread_name undecorated(self.warner.play_thirty_second_warning)(self.warner, warner_thread_name) assert_plugin_played_sound(any_(str))
def test_handle_player_disconnect_while_game_not_in_warmup(self): setup_game_in_progress() self.plugin.current_timer = 42 disconnecting_player = fake_player(1, "Disconnecting Player") connected_players(disconnecting_player) self.plugin.handle_player_disconnect(disconnecting_player, "ragequit") assert_that(self.plugin.current_timer, is_(42))
def test_plays_no_sound_when_next_round_started(self): calling_round_number = 4 setup_game_in_progress(game_type="ca") self.warner.timer_round_number = calling_round_number + 1 undecorated(self.warner.play_thirty_second_warning)( self.warner, calling_round_number) assert_plugin_played_sound(any_(str), times=0)
def setUp(self): setup_plugin() setup_cvars({ "qlx_rebalanceScoreDiffThreshold": "3", "qlx_rebalanceWinningStreakThreshold": "3", "qlx_rebalanceNumAnnouncements": "2" }) setup_game_in_progress() connected_players() self.plugin = auto_rebalance()
def test_handle_team_switch_attempt_unsupported_gametype(self): setup_game_in_progress(game_type="rr") self.setup_balance_ratings([]) player = fake_player(42, "Fake Player") connected_players(player) return_code = self.plugin.handle_team_switch_attempt( player, "spectator", "red") assert_that(return_code, is_(minqlx.RET_NONE))
def setUp(self): setup_plugin() setup_cvars({ "qlx_qlstatsPrivacyKick": "0", "qlx_qlstatsPrivacyBlock": "0", "qlx_qlstatsPrivacyWhitelist": "public, anonymous", "qlx_qlstatsPrivacyJoinAttempts": "5" }) setup_game_in_progress() self.setup_balance_playerprivacy([]) self.plugin = qlstats_privacy_policy()
def setUp(self): setup_plugin() setup_cvars({"qlx_fragstats_toplimit": "10"}) setup_game_in_progress() self.plugin = frag_stats() self.reply_channel = mocked_channel() self.plugin.database = Redis self.db = mock(StrictRedis) self.plugin._db_instance = self.db # pylint: disable=protected-access when(self.db).zincrby(any_, any_, any_).thenReturn(None) when(self.db).zincrby(any_, any_, any_).thenReturn(None) when(self.db).set(any_, any_).thenReturn(None)
def test_handle_round_end_teams_unbalanced(self): setup_game_in_progress(roundlimit=8, red_score=5, blue_score=1) red_player1 = fake_player(123, "Red Player1", "red") red_player2 = fake_player(456, "Red Player2", "red") blue_player1 = fake_player(246, "Blue Player1", "blue") connected_players(red_player1, red_player2, fake_player(42, "Spec Player", "spectator"), blue_player1) return_code = undecorated(self.plugin.handle_round_end)( self.plugin, { "TEAM_WON": "RED" }) assert_that(return_code, is_(minqlx.RET_NONE))
def test_handle_team_switch_with_game_not_in_warmup(self): setup_game_in_progress() switching_player = fake_player(1, "Switching Player", team="spectator") connected_players(switching_player, fake_player(2, "Other Player", team="blue"), fake_player(3, "Other Player", team="red"), fake_player(4, "Other Player", team="blue"), fake_player(5, "Other Player", team="red"), fake_player(6, "Other Player", team="blue"), fake_player(7, "Other Player", team="red"), fake_player(8, "Other Player", team="blue"), fake_player(9, "Other Player", team="red"), fake_player(10, "Other Player", team="blue")) self.plugin.handle_team_switch(switching_player, "spectator", "red") verify(self.timer, times=0).start()
def test_handle_round_end_winner_is_tracked_for_winning_streak(self): setup_game_in_progress(game_type="ca", roundlimit=8, red_score=3, blue_score=1) red_player1 = fake_player(123, "Red Player1", "red") red_player2 = fake_player(456, "Red Player2", "red") blue_player1 = fake_player(246, "Blue Player1", "blue") blue_player2 = fake_player(975, "Blue Player2", "blue") connected_players(red_player1, red_player2, fake_player(42, "Spec Player", "spectator"), blue_player1, blue_player2) self.plugin.winning_teams = ["red", "blue", "red"] undecorated(self.plugin.handle_round_end)(self.plugin, { "TEAM_WON": "RED" }) assert_that(self.plugin.winning_teams, is_(["red", "blue", "red", "red"]))
def test_plays_no_sound_when_game_is_not_clan_arena(self): setup_game_in_progress(game_type="ft") undecorated(self.warner.play_thirty_second_warning)(self.warner, 4) assert_plugin_played_sound(any_(str), times=0)