本文整理汇总了Python中b3.fake.FakeClient.says方法的典型用法代码示例。如果您正苦于以下问题:Python FakeClient.says方法的具体用法?Python FakeClient.says怎么用?Python FakeClient.says使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b3.fake.FakeClient
的用法示例。
在下文中一共展示了FakeClient.says方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cmd_plugin_unload_successful
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [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)
示例2: test_map_with_correct_parameters
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [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')])
示例3: Test_commands
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [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)
示例4: test_cmd_plugin_list
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [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)
示例5: test_cmd_plugin_enable_with_no_plugin_name
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [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)
示例6: test_cmd_plugin_enable_protected
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [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)
示例7: test_cmdalias_no_parameter_no_alias
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [as 别名]
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)
示例8: test_cmd_plugin_enable_with_invalid_plugin_name
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [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)
示例9: test_cmdlevel_no_parameter
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [as 别名]
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)
示例10: test_cmd_plugin_with_invalid_command_name
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [as 别名]
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)
示例11: test_map_with_invalid_map_name
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [as 别名]
def test_map_with_invalid_map_name(self):
# GIVEN
superadmin = FakeClient(self.parser, name="superadmin", guid="guid_superadmin", groupBits=128, team=TEAM_UNKNOWN)
superadmin.connects("1")
# WHEN
superadmin.says("!map blargh blub")
# THEN
self.assertListEqual(["do you mean : buhriz, district, sinjar, siege, uprising, ministry, revolt, heights, "
"contact, peak, panj, market ?"], superadmin.message_history)
示例12: test_cmd_plugin_load_with_invalid_plugin_name
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [as 别名]
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)
示例13: test_cmdlevel_invalid_command
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [as 别名]
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)
示例14: test_cmdlevel_no_parameter_no_access
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [as 别名]
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: test_cmd_plugin_no_parameters
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import says [as 别名]
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)