本文整理汇总了Python中b3.clients.Client.auth方法的典型用法代码示例。如果您正苦于以下问题:Python Client.auth方法的具体用法?Python Client.auth怎么用?Python Client.auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b3.clients.Client
的用法示例。
在下文中一共展示了Client.auth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_guid_readonly
# 需要导入模块: from b3.clients import Client [as 别名]
# 或者: from b3.clients.Client import auth [as 别名]
def test_guid_readonly(self):
c = Client(console=b3.console)
self.assertFalse(c.authed)
c.guid = "foo"
self.assertEqual(c.guid, "foo")
c.auth()
self.assertTrue(c.authed)
# upon guid change, prevent change and consider client not
# authed anymore
c.guid = "bar"
self.assertFalse(c.authed)
c.guid = "foo"
示例2: Test_Client
# 需要导入模块: from b3.clients import Client [as 别名]
# 或者: from b3.clients.Client import auth [as 别名]
class Test_Client(B3TestCase):
def setUp(self):
B3TestCase.setUp(self)
self.client = Client(console=self.console)
def test_construct(self):
c = Client(name="Courgette", guid="1234567890")
self.assertEqual(c.name, "Courgette")
self.assertEqual(c.exactName, "Courgette^7")
self.assertEqual(c.guid, "1234567890")
self.assertEqual(c.team, TEAM_UNKNOWN)
self.assertTrue(c.connected)
self.assertFalse(c.hide)
self.assertEqual(c.ip, '')
self.assertEqual(c.greeting, '')
self.assertEqual(c.pbid, '')
def test_team(self):
m = Mock()
self.client.team = m
self.assertEqual(self.client.team, m)
def test_team_change(self):
self.console.queueEvent = Mock()
self.client.team = 24
self.assertEqual(self.client.team, 24)
self.console.queueEvent.assert_called()
args = self.console.queueEvent.call_args
eventraised = args[0][0]
self.assertEquals(eventraised.type, EVT_CLIENT_TEAM_CHANGE)
self.assertEquals(eventraised.data, 24)
def test_name_change(self):
self.console.queueEvent = Mock()
self.client.authed = True
self.client.name = "cucurb"
self.assertEqual(self.client.name, "cucurb")
self.console.queueEvent.assert_called()
args = self.console.queueEvent.call_args
eventraised = args[0][0]
self.assertEquals(eventraised.type, EVT_CLIENT_NAME_CHANGE)
self.assertEquals(eventraised.data, 'cucurb')
def test_makeAlias_new(self):
self.client.id = 123
self.console.storage.getClientAlias = Mock(side_effect = KeyError())
self.client.makeAlias("bar")
self.assertEquals(self.console.storage.getClientAlias.call_count, 1)
alias = self.console.storage.getClientAlias.call_args[0][0]
self.assertIsInstance(alias, Alias)
self.assertEqual(alias.alias, "bar")
self.assertEqual(alias.numUsed, 1)
def test_makeAlias_existing(self):
self.client.id = 123
aliasFoo = Alias()
aliasFoo.alias = "foo"
aliasFoo.clientId = self.client.id
aliasFoo.numUsed = 48
self.console.storage.getClientAlias = Mock(side_effect = lambda x: aliasFoo)
self.client.makeAlias("whatever")
self.assertEquals(self.console.storage.getClientAlias.call_count, 1)
self.assertIsInstance(aliasFoo, Alias)
self.assertEqual(aliasFoo.alias, "foo")
self.assertEqual(aliasFoo.numUsed, 49)
def test_guid_readonly(self):
self.assertFalse(self.client.authed)
self.client.guid = "foo"
self.assertEqual(self.client.guid, "foo")
self.client.auth()
self.assertTrue(self.client.authed)
# upon guid change, prevent change and consider client not
# authed anymore
self.client.guid = "bar"
self.assertFalse(self.client.authed)
self.client.guid = "foo"
def test_set_ip(self):
self.client.ip = "1.2.3.4"
self.assertEqual(self.client._ip, "1.2.3.4")
self.client.ip = "5.6.7.8:27960"
self.assertEqual(self.client._ip, "5.6.7.8")
def test_makeIpAlias_new(self):
self.client.id = 123
self.console.storage.getClientIpAddress = Mock(side_effect = KeyError())
self.client.makeIpAlias("1.4.7.8")
self.assertEquals(self.console.storage.getClientIpAddress.call_count, 1)
alias = self.console.storage.getClientIpAddress.call_args[0][0]
self.assertIsInstance(alias, IpAlias)
self.assertEqual(alias.ip, "1.4.7.8")
self.assertEqual(alias.numUsed, 1)
def test_makeIpAlias_existing(self):
self.client.id = 123
aliasFoo = IpAlias()
aliasFoo.ip = "9.5.4.4"
aliasFoo.clientId = self.client.id
#.........这里部分代码省略.........