当前位置: 首页>>代码示例>>Python>>正文


Python FakeClient.connects方法代码示例

本文整理汇总了Python中b3.fake.FakeClient.connects方法的典型用法代码示例。如果您正苦于以下问题:Python FakeClient.connects方法的具体用法?Python FakeClient.connects怎么用?Python FakeClient.connects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在b3.fake.FakeClient的用法示例。


在下文中一共展示了FakeClient.connects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Test_stopserverdemo

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
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")
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:36,代码来源:test_stopserverdemo.py

示例2: test_cmd_plugin_unload_successful

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
    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)
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:35,代码来源:test_commands.py

示例3: Cmd_regulars

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
class Cmd_regulars(Admin_functional_test):
    def setUp(self):
        Admin_functional_test.setUp(self)
        self.init()
        self.joe.message = Mock(wraps=lambda x: sys.stdout.write("\t\t" + x + "\n"))
        self.joe.connects(0)

    def test_no_regular(self):
        # only superadmin joe is connected
        self.joe.says("!regulars")
        self.joe.message.assert_called_with("^7There are no regular players online")

    def test_one_regular(self):
        # GIVEN
        self.mike.connects(1)
        self.joe.says("!makereg mike")
        # WHEN
        self.joe.says("!regs")
        # THEN
        self.joe.message.assert_called_with("^7Regular players online: Mike^7")

    def test_two_regulars(self):
        # GIVEN
        self.mike.connects(1)
        self.joe.says("!makereg mike")
        self.jack = FakeClient(self.console, name="Jack", guid="jackguid", groupBits=1)
        self.jack.connects(2)
        self.joe.says("!makereg jack")
        # WHEN
        self.joe.says("!regs")
        # THEN
        self.joe.message.assert_called_with("^7Regular players online: Mike^7, Jack^7")
开发者ID:derfull,项目名称:big-brother-bot,代码行数:34,代码来源:test_admin_functional.py

示例4: StatPluginTestCase

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
class StatPluginTestCase(B3TestCase):

    def setUp(self):
        B3TestCase.setUp(self)

        with logging_disabled():
            admin_conf = CfgConfigParser()
            admin_plugin = AdminPlugin(self.console, admin_conf)
            admin_plugin.onLoadConfig()
            admin_plugin.onStartup()
            when(self.console).getPlugin('admin').thenReturn(admin_plugin)

        conf = CfgConfigParser()
        conf.loadFromString(dedent(r"""
            [commands]
            mapstats-stats: 0
            testscore-ts: 0
            topstats-top: 0
            topxp: 0

            [settings]
            startPoints: 100
            resetscore: no
            resetxp: no
            show_awards: no
            show_awards_xp: no
        """))
        self.p = StatsPlugin(self.console, conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=1, team=TEAM_RED)
        self.mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=1, team=TEAM_RED)
        self.joe.connects(1)
        self.mike.connects(2)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:37,代码来源:__init__.py

示例5: test_existing_player

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 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)
开发者ID:thomasleveil,项目名称:b3-plugin-urt-serverside-demo,代码行数:9,代码来源:test_startserverdemo.py

示例6: test_map_with_correct_parameters

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 def test_map_with_correct_parameters(self):
     # GIVEN
     superadmin = FakeClient(self.parser, name="superadmin", guid="guid_superadmin", groupBits=128, team=TEAM_UNKNOWN)
     superadmin.connects("1")
     # WHEN
     superadmin.says("!map market push")
     # THEN
     self.parser.output.write.assert_has_calls([call('changelevel market push')])
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:10,代码来源:test_insurgency.py

示例7: test_SUICIDE

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 def test_SUICIDE(self):  # 16
     # GIVEN
     poorguy = FakeClient(self.parser, name="attacker_name", guid='76561198070138838')
     poorguy.connects("1")
     # WHEN
     self.parser.handlePacket(Packet.decode('\x00\x10\x00\x00\x00\x08\x01\x10\x00\x01\x06\x8c\x87\xd6'))
     # THEN
     self.assert_has_event("EVT_CLIENT_SUICIDE", client=poorguy, target=poorguy, data=(100, None, None))
开发者ID:BigBrotherBot,项目名称:big-brother-bot,代码行数:10,代码来源:test_chiv.py

示例8: testPlugin5

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 def testPlugin5():
     jack = FakeClient(fakeConsole, name="Jack", _maxLevel=0)
     jack.connects(1)
     time.sleep(1.1)
     joe = FakeClient(fakeConsole, name="Joe", _maxLevel=2)
     joe.connects(2)
     moderator.connects(0)
     moderator.says('!makeroom')
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:10,代码来源:makeroom.py

示例9: Test_commands

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
class Test_commands(CustomcommandsTestCase):

    def setUp(self):
        CustomcommandsTestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.p = CustomcommandsPlugin(self.console, self.conf)
        with logging_disabled():
            from b3.fake import FakeClient
        self.guest = FakeClient(console=self.console, name="Guest", guid="GuestGUID", pbid="GuestPBID", group_bits=0)
        self.user = FakeClient(console=self.console, name="User", guid="UserGUID", pbid="UserPBID", group_bits=1)
        self.regular = FakeClient(console=self.console, name="Regular", guid="RegularGUID", pbid="RegularPBID", group_bits=2)
        self.mod = FakeClient(console=self.console, name="Moderator", guid="ModeratorGUID", pbid="ModeratorPBID", group_bits=8)
        self.admin = FakeClient(console=self.console, name="Admin", guid="AdminGUID", pbid="AdminPBID", group_bits=16)
        self.fulladmin = FakeClient(console=self.console, name="FullAdmin", guid="FullAdminGUID", pbid="FullAdminPBID", group_bits=32)
        self.senioradmin = FakeClient(console=self.console, name="SeniorAdmin", guid="SeniorAdminGUID", pbid="SeniorAdminPBID", group_bits=64)
        self.superadmin = FakeClient(console=self.console, name="SuperAdmin", guid="SuperAdminGUID", pbid="SuperAdminPBID", group_bits=128)

    def test_guest(self):
        # GIVEN
        self.conf.loadFromString("""
[guest commands]
# define in this section commands that will be available to all players
f00 = f00 rcon command
        """)
        # WHEN
        self.p.onLoadConfig()
        self.p.onStartup()
        # THEN
        self.assertIn("f00", self.p._adminPlugin._commands)
        # WHEN
        self.guest.connects(cid="guestCID")
        with patch.object(self.console, "write") as write_mock:
            self.guest.says("!f00")
        # THEN
        self.assertListEqual([call("f00 rcon command")], write_mock.mock_calls)
        self.assertListEqual([], self.guest.message_history)

    def test_user(self):
        # GIVEN
        self.console.getPlugin('admin')._warn_command_abusers = True
        self.conf.loadFromString("""
[user commands]
# define in this section commands that will be available to all players
f00 = f00 rcon command
        """)
        self.p.onLoadConfig()
        self.p.onStartup()
        # WHEN
        self.guest.connects(cid="guestCID")
        with patch.object(self.console, "write") as write_mock:
            self.guest.says("!f00")
        # THEN
        self.assertEqual(1, len(self.guest.message_history))
        self.assertIn(self.guest.message_history[0], [
            'You do not have sufficient access to use !f00',
            'You need to be in group User to use !f00'
        ])
        self.assertListEqual([], write_mock.mock_calls)
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:60,代码来源:test_commands.py

示例10: test_cmd_plugin_enable_protected

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 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)
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:11,代码来源:test_commands.py

示例11: test_cmd_plugin_enable_with_invalid_plugin_name

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 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)
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:11,代码来源:test_commands.py

示例12: test_cmd_plugin_list

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 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)
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:11,代码来源:test_commands.py

示例13: test_cmd_plugin_enable_with_no_plugin_name

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 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)
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:11,代码来源:test_commands.py

示例14: test_low_level

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 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)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:11,代码来源:test_events.py

示例15: test_player_disconnect

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import connects [as 别名]
 def test_player_disconnect(self):
     # GIVEN
     bravo17 = FakeClient(self.parser, name="Bravo17", guid="80a5885ebe2420bab5e158a310fcbc7d")
     bravo17.connects("12")
     self.clear_events()
     # WHEN
     self.parser.routeBattleyeEvent("""Player #12 Bravo17 disconnected""")
     # THEN
     self.assert_has_event("EVT_CLIENT_DISCONNECT", client=bravo17, data='12')
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:11,代码来源:test_arma2.py


注:本文中的b3.fake.FakeClient.connects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。