本文整理汇总了Python中b3.fake.FakeClient.auth方法的典型用法代码示例。如果您正苦于以下问题:Python FakeClient.auth方法的具体用法?Python FakeClient.auth怎么用?Python FakeClient.auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b3.fake.FakeClient
的用法示例。
在下文中一共展示了FakeClient.auth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unexpected_exception
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import auth [as 别名]
def test_unexpected_exception(self):
# GIVEN
when(self.console.storage).getClient(anything()).thenRaise(NotImplementedError())
joe = FakeClient(console=self.console, name="Joe", guid="joe_guid")
# WHEN
with patch.object(self.console, "error") as error_mock:
joe.auth()
# THEN
error_mock.assert_called_with('Auth self.console.storage.getClient(client) - Client<@0:joe_guid|:"Joe":None>',
exc_info=ANY)
示例2: Test_commands
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import auth [as 别名]
class Test_commands(CalladminTestCase):
def setUp(self):
CalladminTestCase.setUp(self)
self.conf = CfgConfigParser()
self.conf.loadFromString(dedent(r"""
[teamspeak]
ip: 127.0.0.1
port: 10011
serverid: 1
username: fakeusername
password: fakepassword
msg_groupid: -1
[settings]
treshold: 3600
useirc: no
[commands]
calladmin: user
"""))
self.p = CalladminPlugin(self.console, self.conf)
self.p.onLoadConfig()
self.p.onStartup()
with logging_disabled():
from b3.fake import FakeClient
self.mike = FakeClient(console=self.console, name="Mike", guid="mikeguid", groupBits=1)
self.bill = FakeClient(console=self.console, name="Bill", guid="billguid", groupBits=16)
####################################################################################################################
## ##
## TEST EVT_CLIENT_CONNECT ##
## ##
####################################################################################################################
def test_admin_connect_with_active_request(self):
# GIVEN
self.p.send_teamspeak_message = Mock()
self.mike.connects('1')
self.mike.says('!calladmin test reason')
# WHEN
self.mike.clearMessageHistory()
self.bill.connects('2')
self.bill.auth()
# THEN
self.p.send_teamspeak_message.assert_has_calls([call('[B][ADMIN REQUEST][/B] [B]Mike[/B] requested an admin on [B]Test Server[/B] : [B]test reason[/B]')])
self.p.send_teamspeak_message.assert_has_calls([call('[B][ADMIN REQUEST][/B] [B]Bill [40][/B] connected to [B]Test Server[/B]')])
self.assertListEqual(['[ADMIN ONLINE] Bill [40]'], self.mike.message_history)
self.assertIsNone(self.p.adminRequest)
####################################################################################################################
## ##
## TEST EVT_CLIENT_DISCONNECT ##
## ##
####################################################################################################################
def test_client_disconnect_with_active_request(self):
# GIVEN
self.p.send_teamspeak_message = Mock()
self.mike.connects('1')
self.mike.says('!calladmin test reason')
# WHEN
self.mike.disconnects()
# THEN
self.p.send_teamspeak_message.assert_has_calls([call('[B][ADMIN REQUEST][/B] [B]Mike[/B] disconnected from [B]Test Server[/B]')])
self.assertIsNone(self.p.adminRequest)