コード例 #1
0
 def test_cmdrevoke_with_client_reconnection(self):
     # GIVEN
     superadmin = FakeClient(self.console,
                             name="superadmin",
                             guid="superadminguid",
                             groupBits=128)
     superadmin.connects("1")
     mike = FakeClient(self.console,
                       id="10",
                       name="mike",
                       guid="mikeguid",
                       groupBits=1)
     mike.connects("2")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdgrant mike cmdlevel")
     superadmin.says("!cmdrevoke mike cmdlevel")
     mike.disconnects()
     del mike  # totally destroy the object
     mike = FakeClient(self.console,
                       id="10",
                       name="mike",
                       guid="mikeguid",
                       groupBits=1)
     mike.connects("2")
     # THEN
     grantlist = getattr(mike, GRANT_SET_ATTR, None)
     self.assertIsNotNone(grantlist)
     self.assertIsInstance(grantlist, set)
     self.assertEqual(0, len(grantlist))
コード例 #2
0
    def test_cmd_plugin_unload_successful(self):
        # GIVEN

        ###### MOCK PLUGIN
        mock_plugin = Mock(spec=Plugin)
        mock_plugin.console = self.console
        mock_plugin.isEnabled = Mock(return_value=False)
        when(self.console).getPlugin("mock").thenReturn(mock_plugin)
        self.console._plugins['mock'] = mock_plugin
        ###### MOCK COMMAND
        mock_func = Mock()
        mock_func.__name__ = 'cmd_mockfunc'
        self.adminPlugin._commands['mockcommand'] = Command(plugin=mock_plugin, cmd='mockcommand', level=100, func=mock_func)
        ###### MOCK EVENT
        mock_plugin.onSay = Mock()
        mock_plugin.registerEvent('EVT_CLIENT_SAY', mock_plugin.onSay)
        ###### MOCK CRON
        mock_plugin.mockCronjob = Mock()
        mock_plugin.mockCrontab = b3.cron.PluginCronTab(mock_plugin, mock_plugin.mockCronjob, minute='*', second= '*/60')
        self.console.cron.add(mock_plugin.mockCrontab)
        self.assertIn(id(mock_plugin.mockCrontab), self.console.cron._tabs)

        superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
        superadmin.connects("1")
        # WHEN
        superadmin.clearMessageHistory()
        superadmin.says("!plugin unload mock")
        # THEN
        self.assertNotIn('mockcommand', self.adminPlugin._commands)
        self.assertIn(self.console.getEventID('EVT_CLIENT_SAY'), self.console._handlers)
        self.assertNotIn(mock_plugin, self.console._handlers[self.console.getEventID('EVT_CLIENT_SAY')])
        self.assertNotIn(id(mock_plugin.mockCrontab), self.console.cron._tabs)
        self.assertListEqual(['Plugin mock has been unloaded'], superadmin.message_history)
コード例 #3
0
class Test_stopserverdemo(PluginTestCase):
    CONF = """\
[commands]
stopserverdemo = 20
"""
    def setUp(self):
        PluginTestCase.setUp(self)
        self.p.onStartup()
        self.moderator = FakeClient(self.console, name="Moderator", exactName="Moderator", guid="654654654654654654", groupBits=8)
        self.moderator.connects('0')
        self.moderator.clearMessageHistory()


    def test_no_parameter(self):
        self.moderator.says("!stopserverdemo")
        self.assertListEqual(["specify a player name or 'all'"], self.moderator.message_history)

    def test_non_existing_player(self):
        self.moderator.says("!stopserverdemo foo")
        self.assertListEqual(['No players found matching foo'], self.moderator.message_history)

    def test_all(self):
        self.p._recording_all_players = True
        when(self.console).write("stopserverdemo all").thenReturn("stopserverdemo: stopped recording laCourge")
        self.moderator.says("!stopserverdemo all")
        self.assertFalse(self.p._recording_all_players)
        self.assertListEqual(['stopserverdemo: stopped recording laCourge'], self.moderator.message_history)

    def test_existing_player(self):
        joe = FakeClient(self.console, name="Joe", guid="01230123012301230123", groupBits=1)
        joe.connects('1')
        self.assertEqual(joe, self.console.clients['1'])
        when(self.console).write("stopserverdemo 1").thenReturn("stopserverdemo: stopped recording Joe")
        self.moderator.says("!stopserverdemo joe")
コード例 #4
0
 def test_cmdgrant_with_lower_group_level(self):
     # GIVEN
     superadmin = FakeClient(self.console,
                             name="superadmin",
                             guid="superadminguid",
                             groupBits=128)
     superadmin.connects("1")
     mike = FakeClient(self.console,
                       name="mike",
                       guid="mikeguid",
                       groupBits=1)
     mike.connects("2")
     # WHEN
     superadmin.clearMessageHistory()
     mike.clearMessageHistory()
     mike.says("!cmdlevel cmdlevel")
     superadmin.says("!cmdgrant mike cmdlevel")
     mike.says("!cmdlevel cmdlevel")
     # THEN
     grantlist = getattr(mike, GRANT_SET_ATTR, None)
     self.assertIsNotNone(grantlist)
     self.assertIn('cmdlevel', grantlist)
     self.assertLess(mike.maxLevel,
                     self.adminPlugin._commands['cmdlevel'].level[0])
     self.assertListEqual(['mike has now a grant for cmdlevel command'],
                          superadmin.message_history)
     self.assertListEqual([
         'You need to be in group Full Admin to use !cmdlevel',
         'command cmdlevel level: fulladmin'
     ], mike.message_history)
コード例 #5
0
class Test_startserverdemo(PluginTestCase):
    CONF = """\
[commands]
startserverdemo = 20
"""
    def setUp(self):
        PluginTestCase.setUp(self)
        self.p.onStartup()
        self.moderator = FakeClient(self.console, name="Moderator", exactName="Moderator", guid="654654654654654654", groupBits=8)
        self.moderator.connects('0')
        self.moderator.clearMessageHistory()


    def test_no_parameter(self):
        self.moderator.says("!startserverdemo")
        self.assertListEqual(["specify a player name or 'all'"], self.moderator.message_history)

    def test_non_existing_player(self):
        self.moderator.says("!startserverdemo foo")
        self.assertListEqual(['No players found matching foo'], self.moderator.message_history)

    def test_all(self):
        self.p._recording_all_players = False
        when(self.console).write("startserverdemo all").thenReturn("startserverdemo: recording laCourge to serverdemos/2012_04_22_20-16-38_laCourge_642817.dm_68")
        self.moderator.says("!startserverdemo all")
        self.assertTrue(self.p._recording_all_players)
        self.assertListEqual(['startserverdemo: recording laCourge to serverdemos/2012_04_22_20-16-38_laCourge_642817.dm_68'], self.moderator.message_history)

    def test_existing_player(self):
        joe = FakeClient(self.console, name="Joe", guid="01230123012301230123", groupBits=1)
        joe.connects('1')
        self.assertEqual(joe, self.console.clients['1'])
        when(self.console).write("startserverdemo 1").thenReturn("startserverdemo: recording Joe to serverdemos/2012_04_22_20-16-38_Joe_642817.dm_68")
        self.moderator.says("!startserverdemo joe")
        self.assertListEqual(['startserverdemo: recording Joe to serverdemos/2012_04_22_20-16-38_Joe_642817.dm_68'], self.moderator.message_history)
コード例 #6
0
 def test_cmdlevel_invalid_command(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdlevel fakecommand")
     # THEN
     self.assertListEqual(['could not find command fakecommand'], superadmin.message_history)
コード例 #7
0
 def test_cmdlevel_no_parameter_no_access(self):
     # GIVEN
     mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=32)
     mike.connects("1")
     # WHEN
     mike.clearMessageHistory()
     mike.says("!cmdlevel die")
     # THEN
     self.assertListEqual(['no sufficient access to die command'], mike.message_history)
コード例 #8
0
 def test_cmdlevel_no_parameter(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdlevel help")
     # THEN
     self.assertListEqual(['command help level: guest'], superadmin.message_history)
コード例 #9
0
 def test_cmdalias_no_parameter_no_alias(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdalias register")
     # THEN
     self.assertListEqual(['command register has not alias set'], superadmin.message_history)
コード例 #10
0
 def test_cmd_plugin_load_with_invalid_plugin_name(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!plugin load fake")
     # THEN
     self.assertListEqual(['Missing fake plugin python module', 'Please put the plugin module in @b3/extplugins/'], superadmin.message_history)
コード例 #11
0
 def test_cmdlevel_invalid_command(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdlevel fakecommand")
     # THEN
     self.assertListEqual(['could not find command fakecommand'], superadmin.message_history)
コード例 #12
0
 def test_cmd_plugin_with_invalid_command_name(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!plugin fake")
     # THEN
     self.assertListEqual(['usage: !plugin <disable|enable|info|list|load|unload> [<data>]'], superadmin.message_history)
コード例 #13
0
 def test_cmd_plugin_list(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!plugin list")
     # THEN
     self.assertListEqual(['Loaded plugins: admin, pluginmanager'], superadmin.message_history)
コード例 #14
0
 def test_cmdlevel_no_parameter_no_access(self):
     # GIVEN
     mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=32)
     mike.connects("1")
     # WHEN
     mike.clearMessageHistory()
     mike.says("!cmdlevel die")
     # THEN
     self.assertListEqual(['no sufficient access to die command'], mike.message_history)
コード例 #15
0
 def test_cmdlevel_no_parameter(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdlevel help")
     # THEN
     self.assertListEqual(['command help level: guest'], superadmin.message_history)
コード例 #16
0
 def test_cmd_plugin_enable_with_no_plugin_name(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!plugin enable")
     # THEN
     self.assertListEqual(['usage: !plugin enable <name/s>'], superadmin.message_history)
コード例 #17
0
 def test_cmd_plugin_enable_with_invalid_plugin_name(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!plugin enable fake")
     # THEN
     self.assertListEqual(['Plugin fake is not loaded'], superadmin.message_history)
コード例 #18
0
 def test_cmd_plugin_enable_protected(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!plugin enable admin")
     # THEN
     self.assertListEqual(['Plugin admin is protected'], superadmin.message_history)
コード例 #19
0
 def test_low_level(self):
     # GIVEN
     joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=8)
     # WHEN
     joe.clearMessageHistory()
     joe.connects("0")
     # THEN
     self.assertEqual([], joe.message_history)
     self.assertEqual(8, joe.groupBits)
コード例 #20
0
 def test_high_level_no_password_set(self):
     # GIVEN
     joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=128)
     # WHEN
     joe.clearMessageHistory()
     joe.connects("0")
     # THEN
     self.assertEqual(['You need a password to use all your privileges: ask the administrator to set a password for you'], joe.message_history)
     self.assertEqual(2, joe.groupBits)
コード例 #21
0
 def test_cmdalias_no_parameter_no_alias(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdalias register")
     # THEN
     self.assertListEqual(['command register has not alias set'], superadmin.message_history)
コード例 #22
0
 def test_cmd_plugin_no_parameters(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!plugin")
     # THEN
     self.assertListEqual(['invalid data, try !help plugin'], superadmin.message_history)
コード例 #23
0
class Test_cmd_xlrstats(XlrstatsTestCase):

    def setUp(self):
        XlrstatsTestCase.setUp(self)
        self.init()
        self.p1 = FakeClient(console=self.console, name="P1", guid="P1_GUID")
        self.p1.connects("1")
        self.p2 = FakeClient(console=self.console, name="P2", guid="P2_GUID")
        self.p2.connects("2")

    def test_unregistered_player(self):
        # GIVEN
        self.console.getPlugin('admin')._warn_command_abusers = True
        self.p1.clearMessageHistory()
        # WHEN
        self.p1.says("!xlrstats")
        # THEN
        self.assertEqual(['You need to be in group User to use !xlrstats'], self.p1.message_history)

    def test_registered_player(self):
        # GIVEN
        self.console.getPlugin('admin')._warn_command_abusers = True
        self.p1.says("!register")
        self.p1.clearMessageHistory()
        # WHEN
        self.p1.says("!xlrstats")
        # THEN
        self.assertEqual(['XLR Stats: P1 : K 0 D 0 TK 0 Ratio 0.00 Skill 1000.00'], self.p1.message_history)

    def test_for_unknown_player(self):
        # GIVEN
        self.p1.says("!register")
        self.p1.clearMessageHistory()
        # WHEN
        self.p1.says("!xlrstats spiderman")
        # THEN
        self.assertEqual(['No players found matching spiderman'], self.p1.message_history)

    def test_for_other_unregistered_player(self):
        # GIVEN
        self.p1.says("!register")
        self.p1.clearMessageHistory()
        # WHEN
        self.p1.says("!xlrstats P2")
        # THEN
        self.assertEqual(['XLR Stats: could not find stats for P2'], self.p1.message_history)

    def test_for_other_registered_player(self):
        # GIVEN
        self.p1.says("!register")
        self.p2.says("!register")
        self.p1.clearMessageHistory()
        # WHEN
        self.p1.says("!xlrstats P2")
        # THEN
        self.assertEqual(['XLR Stats: P2 : K 0 D 0 TK 0 Ratio 0.00 Skill 1000.00'], self.p1.message_history)
コード例 #24
0
 def test_high_level_having_password(self):
     # GIVEN
     joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=128, password=F00_MD5)
     joe.save()
     # WHEN
     joe.clearMessageHistory()
     joe.connects("0")
     # THEN
     self.assertEqual(['Login via console: /tell 0 !login yourpassword'], joe.message_history)
     self.assertEqual(2, joe.groupBits)
コード例 #25
0
 def test_low_level(self):
     # GIVEN
     joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=8)
     joe.connects("0")
     # WHEN
     joe.clearMessageHistory()
     joe.says("!login")
     # THEN
     self.assertEqual(['You do not need to log in'], joe.message_history)
     self.assertFalse(self.jack.isvar(self.p, 'loggedin'))
コード例 #26
0
def moderator(console):
    with logging_disabled():
        from b3.fake import FakeClient
    moderator = FakeClient(console,
                           name="Moderator",
                           guid="moderator_guid",
                           groupBits=8,
                           team=TEAM_UNKNOWN)
    moderator.clearMessageHistory()
    return moderator
コード例 #27
0
def joe(console):
    with logging_disabled():
        from b3.fake import FakeClient
    joe = FakeClient(console,
                     name="Joe",
                     guid="joe_guid",
                     groupBits=1,
                     team=TEAM_UNKNOWN)
    joe.clearMessageHistory()
    return joe
コード例 #28
0
def superadmin(console):
    with logging_disabled():
        from b3.fake import FakeClient
    client = FakeClient(console,
                        name="Superadmin",
                        guid="superadmin_guid",
                        groupBits=128,
                        team=TEAM_UNKNOWN)
    client.clearMessageHistory()
    return client
コード例 #29
0
 def test_low_level(self):
     # GIVEN
     joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=8)
     joe.connects("0")
     # WHEN
     joe.clearMessageHistory()
     joe.says("!login")
     # THEN
     self.assertEqual(['You do not need to log in'], joe.message_history)
     self.assertFalse(self.jack.isvar(self.p, 'loggedin'))
コード例 #30
0
def jack(console):
    with logging_disabled():
        from b3.fake import FakeClient
    client = FakeClient(console,
                        name="Jack",
                        guid="jack_guid",
                        groupBits=1,
                        team=TEAM_UNKNOWN)
    client.clearMessageHistory()
    return client
コード例 #31
0
 def test_already_logged_in(self):
     # GIVEN
     joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=128)
     joe.setvar(self.p, 'loggedin', 1)
     joe.connects("0")
     # WHEN
     joe.clearMessageHistory()
     joe.says("!login")
     # THEN
     self.assertEqual(['You are already logged in'], joe.message_history)
コード例 #32
0
 def test_cmdrevoke_with_no_grant_given(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     mike = FakeClient(self.console, name="mike", guid="mikeguid", groupBits=64)
     mike.connects("2")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdrevoke mike cmdlevel")
     # THEN
     self.assertListEqual(['mike has no grant for cmdlevel command'], superadmin.message_history)
コード例 #33
0
 def test_cmdalias_update_alias(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     self.assert_cmd_alias("help", "h")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdalias help newhelp")
     # THEN
     self.assertListEqual(['updated alias for command help: newhelp'], superadmin.message_history)
     self.assert_cmd_alias("help", "newhelp")
コード例 #34
0
 def test_cmduse_access(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     mike = FakeClient(self.console, name="mike", guid="mikeguid", groupBits=64)
     mike.connects("2")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmduse mike cmdlevel")
     # THEN
     self.assertListEqual(['mike has access to cmdlevel command'], superadmin.message_history)
コード例 #35
0
 def test_cmdlevel_single_invalid_minlevel(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     self.assert_cmd_groups("help", "^2guest")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdlevel help fakegroup")
     # THEN
     self.assertListEqual(['invalid level specified: fakegroup'], superadmin.message_history)
     self.assert_cmd_groups("help", "^2guest")
コード例 #36
0
 def test_cmduse_access(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     mike = FakeClient(self.console, name="mike", guid="mikeguid", groupBits=64)
     mike.connects("2")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmduse mike cmdlevel")
     # THEN
     self.assertListEqual(['mike has access to cmdlevel command'], superadmin.message_history)
コード例 #37
0
 def test_cmdlevel_double_minlevel_greater_than_maxlevel(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     self.assert_cmd_groups("help", "^2guest")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdlevel help fulladmin-admin")
     # THEN
     self.assertListEqual(['invalid level: fulladmin is greater than admin'], superadmin.message_history)
     self.assert_cmd_groups("help", "^2guest")
コード例 #38
0
 def test_cmdlevel_double_valid_minlevel_maxlevel(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     self.assert_cmd_groups("help", "^2guest")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdlevel help admin-senioradmin")
     # THEN
     self.assertListEqual(['command help level changed: admin-senioradmin'], superadmin.message_history)
     self.assert_cmd_groups("help", "^2admin^7-^2senioradmin")
コード例 #39
0
 def test_cmd_plugin_load_with_already_loaded_plugin(self):
     # GIVEN
     mock_plugin = Mock(spec=Plugin)
     when(self.console).getPlugin("mock").thenReturn(mock_plugin)
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!plugin load mock")
     # THEN
     self.assertListEqual(['Plugin mock is already loaded'], superadmin.message_history)
コード例 #40
0
 def test_cmdrevoke_with_no_grant_given(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     mike = FakeClient(self.console, name="mike", guid="mikeguid", groupBits=64)
     mike.connects("2")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdrevoke mike cmdlevel")
     # THEN
     self.assertListEqual(['mike has no grant for cmdlevel command'], superadmin.message_history)
コード例 #41
0
def bot(console):
    with logging_disabled():
        from b3.fake import FakeClient
    client = FakeClient(console,
                        name="Bot",
                        guid="bot_guid",
                        groupBits=1,
                        team=TEAM_UNKNOWN,
                        bot=True)
    client.clearMessageHistory()
    return client
コード例 #42
0
 def test_cmdalias_add_alias(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     self.assert_cmd_alias("register", None)
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdalias register newregister")
     # THEN
     self.assertListEqual(['added alias for command register: newregister'], superadmin.message_history)
     self.assert_cmd_alias("register", "newregister")
コード例 #43
0
 def test_cmdlevel_single_invalid_minlevel(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     self.assert_cmd_groups("help", "^2guest")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdlevel help fakegroup")
     # THEN
     self.assertListEqual(['invalid level specified: fakegroup'], superadmin.message_history)
     self.assert_cmd_groups("help", "^2guest")
コード例 #44
0
    def test_cmdlevel_single_valid_minlevel(self):
        # GIVEN
        superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
        superadmin.connects("1")

        # WHEN
        superadmin.clearMessageHistory()
        superadmin.says("!cmdlevel help admin")
        # THEN
        self.assertListEqual(['command help level changed: admin'], superadmin.message_history)
        self.assert_cmd_groups("help", "^2admin")
コード例 #45
0
 def test_cmdalias_already_in_use(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     self.assert_cmd_alias("ban", "b")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdalias ban tempban")
     # THEN
     self.assertListEqual(['command tempban is already in use'], superadmin.message_history)
     self.assert_cmd_alias("ban", "b")
コード例 #46
0
 def test_cmdalias_invalid_alias_specified(self):
     # GIVEN
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     self.assert_cmd_alias("help", "h")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!cmdalias help !")
     # THEN
     self.assertListEqual(['invalid data, try !help cmdalias'], superadmin.message_history)
     self.assert_cmd_alias("help", "h")
コード例 #47
0
 def test_cmd_plugin_unload_with_enabled_plugin(self):
     # GIVEN
     mock_plugin = Mock(spec=Plugin)
     mock_plugin.isEnabled = Mock(return_value=True)
     when(self.console).getPlugin("mock").thenReturn(mock_plugin)
     superadmin = FakeClient(self.console, name="superadmin", guid="superadminguid", groupBits=128)
     superadmin.connects("1")
     # WHEN
     superadmin.clearMessageHistory()
     superadmin.says("!plugin unload mock")
     # THEN
     self.assertListEqual(['Plugin mock is currently enabled: disable it first'], superadmin.message_history)