本文整理汇总了Python中b3.fake.FakeClient.radios方法的典型用法代码示例。如果您正苦于以下问题:Python FakeClient.radios方法的具体用法?Python FakeClient.radios怎么用?Python FakeClient.radios使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b3.fake.FakeClient
的用法示例。
在下文中一共展示了FakeClient.radios方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Test_game_specific_spam
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import radios [as 别名]
class Test_game_specific_spam(SpamcontrolTestCase):
def setUp(self):
SpamcontrolTestCase.setUp(self)
with open(SPAMCONTROM_CONFIG_FILE) as default_conf:
self.init_plugin(default_conf.read())
self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="zaerezarezar", groupBits=1)
self.joe.connects("1")
# let's say our game has a new event : EVT_CLIENT_RADIO
EVT_CLIENT_RADIO = self.console.Events.createEvent('EVT_CLIENT_RADIO', 'Event client radio')
# teach the Spamcontrol plugin how to react on such events
def onRadio(event):
new_event = Event(type=event.type, client=event.client, target=event.target, data=event.data['text'])
self.p.onChat(new_event)
self.p.eventHanlders[EVT_CLIENT_RADIO] = onRadio
self.p.registerEvent(EVT_CLIENT_RADIO)
# patch joe to make him able to send radio messages
def radios(me, text):
me.console.queueEvent(Event(type=EVT_CLIENT_RADIO, client=me, data={'text': text}))
self.joe.radios = new.instancemethod(radios, self.joe, FakeClient)
def test_radio_spam(self):
when(self.p).getTime().thenReturn(0)
self.joe.warn = Mock()
self.joe.says("doh 1")
self.joe.radios("doh 2")
self.joe.says("doh 3")
self.joe.radios("doh 4")
self.joe.says("doh 5")
self.assertEqual(1, self.joe.warn.call_count)