def test_handle_player_connect_no_game_running(self): setup_no_game() connecting_player = fake_player(123, "Connecting Player") self.plugin.handle_player_connect(connecting_player) assert_plugin_sent_to_console(any, times=0)
def test_handle_player_connect_plugin_disable(self): self.plugin.plugin_enabled = False connecting_player = fake_player(123, "Connecting Player") self.plugin.handle_player_connect(connecting_player) assert_plugin_sent_to_console(any, times=0)
def test_handle_vote_called_for_not_for_mode_change(self): voting_player = fake_player(123, "Voting Player", _id=3) return_code = self.plugin.handle_vote_called(voting_player, "map", "campgrounds ca") assert_that(return_code, is_(minqlx.RET_NONE)) verify(Plugin, times=0).callvote(any_, any_) verify(minqlx, times=0).client_command(any_, any_) assert_plugin_sent_to_console(any_, times=0)
def test_handle_vote_called_for_already_running_mode(self): voting_player = fake_player(123, "Voting Player", _id=3) return_code = self.plugin.handle_vote_called(voting_player, "mode", "vql") assert_that(return_code, is_(minqlx.RET_STOP_ALL)) verify(Plugin, times=0).callvote(any_, any_) verify(minqlx, times=0).client_command(any_, any_) assert_plugin_sent_to_console(any_, times=0)
def test_handle_vote_called_for_pql(self): voting_player = fake_player(123, "Voting Player", _id=3) return_code = self.plugin.handle_vote_called(voting_player, "mode", "pql") assert_that(return_code, is_(minqlx.RET_STOP_ALL)) verify(Plugin).callvote("mode pql", "mode pql") verify(minqlx).client_command(voting_player.id, "vote yes") assert_plugin_sent_to_console(matches(r".*called a vote\."))
def test_handle_team_switch_attempt_no_balance_plugin_loaded(self): self.setup_no_balance_plugin() 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)) assert_plugin_sent_to_console(matches(".*not possible.*"))
def test_cmd_switch_plugin_moves_anonymous_players_to_spec(self): self.plugin.plugin_enabled = False reply_channel = mocked_channel() red_player = fake_player(123, "Red Player", "red") blue_player = fake_player(456, "Blue Player", "blue") connected_players(red_player, blue_player) self.setup_balance_playerprivacy([(red_player, "public"), (blue_player, "private")]) self.plugin.cmd_switch_plugin(None, ["!policy"], reply_channel) assert_player_was_put_on(red_player, "spectator", times=0) assert_player_was_told(red_player, any, times=0) assert_player_was_put_on(blue_player, "spectator") assert_player_was_told(blue_player, matches(".*Open qlstats.net.*")) assert_player_received_center_print(blue_player, matches(".*Join not allowed.*")) assert_plugin_sent_to_console(matches(".*not allowed to join.*"))
def test_handle_team_switch_attempt_player_has_forbidden_privacy_setting_moved_to_spec( self): specced_player = fake_player(123, "Test Player") connected_players(specced_player) # noinspection PyUnresolvedReferences self.plugin.plugins["balance"].player_info = { specced_player.steam_id: { "privacy": "private" } } self.plugin.handle_team_switch_attempt(specced_player, "red", "blue") assert_plugin_sent_to_console(matches(".*not allowed to join.*")) assert_player_received_center_print(specced_player, matches(r"\^3Join not allowed.*")) assert_player_was_told(specced_player, matches(".*Open qlstats.net.*")) assert_player_was_put_on(specced_player, "spectator")
def test_handle_team_switch_attempt_player_has_forbidden_privacy_setting( self): specced_player = fake_player(123, "Test Player") connected_players(specced_player) # noinspection PyUnresolvedReferences self.plugin.plugins["balance"].player_info = { specced_player.steam_id: { "privacy": "private" } } return_code = self.plugin.handle_team_switch_attempt( specced_player, "spectator", "any") assert_plugin_sent_to_console(matches(".*not allowed to join.*")) assert_player_received_center_print(specced_player, matches(r"\^3Join not allowed.*")) assert_player_was_told(specced_player, matches(".*Open qlstats.net.*")) assert_that(return_code, is_(minqlx.RET_STOP_ALL)) assert_that(specced_player.steam_id in self.plugin.join_attempts, is_(True))
def test_callback_connect_players_not_kicked(self): self.plugin.callback_connect([123], None) assert_plugin_sent_to_console(any_, times=0)
def test_callback_connect_players_plugin_disabled(self): self.plugin.plugin_enabled = False self.plugin.callback_connect([123], None) assert_plugin_sent_to_console(any, times=0)
def test_constructor(): assert_plugin_sent_to_console(matches("mydiscordbot Version: "), atleast=1)
def test_cmd_discord_message_triggered(self): triggering_player = fake_player(1, "Triggering Player") self.plugin.cmd_discord(triggering_player, ["!discord", "asdf"], minqlx.CHAT_CHANNEL) verify(self.discord).triggered_message(triggering_player, "asdf") assert_plugin_sent_to_console("Message to Discord chat cast!")