Esempio n. 1
0
    def test_cmd_switch_plugin_shows_usage(self):
        reply_channel = mocked_channel()

        return_code = self.plugin.cmd_switch_plugin(None, ["!policy", "asdf"],
                                                    reply_channel)

        assert_that(return_code, is_(minqlx.RET_USAGE))
Esempio n. 2
0
    def test_cmd_switch_plugin_shows_usage_for_too_many_parameters(self):
        reply_channel = mocked_channel()

        return_code = self.plugin.cmd_switch_plugin(
            None, ["!policy", "too", "many", "parameters"], reply_channel)

        assert_that(return_code, is_(minqlx.RET_USAGE))
Esempio n. 3
0
    def test_cmd_soulz_in_team_chat_channel(self):
        player = fake_player(123, "Issuing Player", team="red")
        minqlx.CHAT_CHANNEL = mocked_channel()

        killed1 = fake_player(4, "Killed1", team="blue")
        killed2 = fake_player(5, "Killed2", team="blue")
        killed3 = fake_player(6, "Killed3", team="blue")
        killed4 = fake_player(7, "Killed4", team="blue")
        connected_players(player, killed1, killed2, killed3, killed4)

        when(self.db).zrevrangebyscore(f"minqlx:players:{player.steam_id}:soulz",
                                       "+INF", "-INF", start=0, num=10, withscores=True)\
            .thenReturn([
                (killed1.steam_id, 2),
                (killed2.steam_id, 3),
                (killed3.steam_id, 5),
                (killed4.steam_id, 8)
            ])

        self.plugin.cmd_soulz(player, ["!soulz"], minqlx.RED_TEAM_CHAT_CHANNEL)

        assert_channel_was_replied(
            minqlx.CHAT_CHANNEL,
            matches(
                r"Top 10 reaped soulz for Issuing Player.*: "
                r"Killed4.* \(8\), Killed3.* \(5\), Killed2.* \(3\), Killed1.* \(2\)"
            ))
Esempio n. 4
0
    def test_cmd_switch_plugin_disabled(self):
        self.plugin.plugin_enabled = False
        reply_channel = mocked_channel()

        self.plugin.cmd_switch_plugin(None, ["!policy", "status"],
                                      reply_channel)

        assert_channel_was_replied(reply_channel, matches(".*disabled.*"))
Esempio n. 5
0
    def test_cmd_switch_plugin_disable_policy_check(self):
        reply_channel = mocked_channel()

        self.plugin.cmd_switch_plugin(None, ["!policy"], reply_channel)

        assert_channel_was_replied(
            reply_channel, matches(".*QLStats policy check disabled.*"))
        assert_that(self.plugin.plugin_enabled, is_(False))
Esempio n. 6
0
    def test_cmd_switch_plugin_with_no_balance_plugin(self):
        minqlx.Plugin._loaded_plugins.pop("balance")  # pylint: disable=protected-access
        self.plugin.plugin_enabled = False
        reply_channel = mocked_channel()
        connected_players()

        self.plugin.cmd_switch_plugin(None, ["!policy"], reply_channel)

        assert_that(self.plugin.plugin_enabled, is_(False))
Esempio n. 7
0
    def test_cmd_switch_plugin_enables_policy_check(self):
        self.plugin.plugin_enabled = False
        reply_channel = mocked_channel()
        connected_players()

        self.plugin.cmd_switch_plugin(None, ["!policy"], reply_channel)

        assert_that(self.plugin.plugin_enabled, is_(True))
        assert_channel_was_replied(reply_channel,
                                   matches(".*QLStats policy check enabled.*"))
Esempio n. 8
0
    def test_cmd_switch_plugin_moves_unfetched_rated_players_to_spec(self):
        self.plugin.plugin_enabled = False
        reply_channel = mocked_channel()
        red_player = fake_player(123, "Red Player", "red")
        connected_players(red_player, )
        self.setup_balance_playerprivacy([])

        self.plugin.cmd_switch_plugin(None, ["!policy"], reply_channel)

        assert_player_was_put_on(red_player, "spectator")
        assert_player_was_told(red_player,
                               matches(".*couldn't fetch your ratings.*"))
Esempio n. 9
0
    def test_cmd_switch_plugin_kicks_players(self):
        self.plugin.plugin_enabled = False
        self.plugin.kick_players = True
        reply_channel = mocked_channel()
        kicked_player = fake_player(123, "Test Player")
        connected_players(kicked_player)
        self.setup_balance_playerprivacy([(kicked_player, "private")])
        self.plugin.delayed_kick = mock()
        when(self.plugin).delayed_kick(any_, any_(str)).thenReturn(None)

        self.plugin.cmd_switch_plugin(None, ["!policy"], reply_channel)

        verify(self.plugin).delayed_kick(kicked_player.steam_id, any_)
Esempio n. 10
0
    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)
Esempio n. 11
0
    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.*"))