本文整理汇总了Python中b3.clients.Client.save方法的典型用法代码示例。如果您正苦于以下问题:Python Client.save方法的具体用法?Python Client.save怎么用?Python Client.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b3.clients.Client
的用法示例。
在下文中一共展示了Client.save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_auth_client_without_guid_but_with_known_pbid
# 需要导入模块: from b3.clients import Client [as 别名]
# 或者: from b3.clients.Client import save [as 别名]
def test_auth_client_without_guid_but_with_known_pbid(self):
# GIVEN
# known superadmin named Snoopy
superadmin = Client(console=self.parser, name='Snoopy', guid='EA_AAAAAAAABBBBBBBBBBBBBB00000000000012222', pbid='300000aaaaaabbbbbbccccc111223300', group_bits=128, connections=21)
superadmin.save()
# bf3 server failing to provide guid
def write(data):
if data == ('admin.listPlayers', 'player', 'Snoopy'):
return ['7', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', '1', 'Snoopy', '', '2', '8', '0', '0', '0']
else:
return DEFAULT
self.write_mock.side_effect = write
# WHEN
self.assertFalse('Snoopy' in self.parser.clients)
self.parser.OnPBPlayerGuid(match=re.match(self.regex_for_OnPBPlistItem, self.event_raw_data), data=self.event_raw_data)
# THEN
# B3 should have authed Snoopy
self.assertTrue('Snoopy' in self.parser.clients)
snoopy = self.parser.clients['Snoopy']
self.assertTrue(snoopy.authed)
for attb in ('name', 'pbid', 'guid', 'groupBits'):
self.assertEqual(getattr(superadmin, attb), getattr(snoopy, attb))
示例2: Test_Client_events
# 需要导入模块: from b3.clients import Client [as 别名]
# 或者: from b3.clients.Client import save [as 别名]
class Test_Client_events(B3TestCase):
def setUp(self):
B3TestCase.setUp(self)
self.queueEvent_patcher = patch.object(self.console, 'queueEvent')
self.queueEvent_mock = self.queueEvent_patcher.start()
self.admin = Client(console=self.console)
self.client = Client(console=self.console)
self.client.save()
def tearDown(self):
B3TestCase.tearDown(self)
self.queueEvent_patcher.stop()
def test_warn(self):
with self.assertRaiseEvent(event_type="EVT_CLIENT_WARN", event_client=self.client, event_data={
'reason': 'insulting admin',
'duration': 5*60,
'data': 'foobar',
'admin': self.admin,
'timeExpire': ANY
}, event_target=None):
self.client.warn(duration='5h', warning='insulting admin', keyword=None, admin=self.admin, data='foobar')
def test_notice(self):
with self.assertRaiseEvent(event_type="EVT_CLIENT_NOTICE", event_client=self.client, event_data={
'notice': "keep a eye on this guy",
'admin': self.admin,
'timeAdd': ANY
}):
self.client.notice(notice="keep a eye on this guy", spare=None, admin=self.admin)
示例3: test_one_ban_with_reason
# 需要导入模块: from b3.clients import Client [as 别名]
# 或者: from b3.clients.Client import save [as 别名]
def test_one_ban_with_reason(self):
# GIVEN
player1 = Client(console=self.console, guid='BillGUID', name="Bill")
player1.save()
penalty1 = ClientBan(clientId=player1.id, timeExpire=-1, adminId=0, reason="test reason")
when(self.console.storage).getLastPenalties(types=whatever(), num=whatever()).thenReturn([penalty1])
# WHEN
self.lastbans()
# THEN
self.mock_command.sayLoudOrPM.assert_called_once_with(self.player, u'^[email protected]^7 Bill^7^7 (Perm) test reason')
示例4: test_known_client_by_cid
# 需要导入模块: from b3.clients import Client [as 别名]
# 或者: from b3.clients.Client import save [as 别名]
def test_known_client_by_cid(self):
# GIVEN
known_client = Client(console=self.parser, guid="AAAAAAAAAAAA000000000000000", name="theName")
known_client.save()
self.assertEqual(1, len(self.parser.clients))
self.assertDictContainsSubset({'clients': 2}, self.parser.storage.getCounts())
# WHEN
client = self.parser.getClientOrCreate(cid="2", guid="AAAAAAAAAAAA000000000000000", name="newName", team="CT")
# THEN
self.assertIsInstance(client, Client)
self.assertEqual(known_client.id, client.id)
self.assertEqual("2", client.cid)
self.assertEqual("AAAAAAAAAAAA000000000000000", client.guid)
self.assertEqual("newName", client.name)
self.assertEqual(TEAM_RED, client.team)
self.assertTrue(client.authed)
self.assertEqual(2, len(self.parser.clients))
self.assertDictContainsSubset({'clients': 2}, self.parser.storage.getCounts())
示例5: test_two_bans_with_reason
# 需要导入模块: from b3.clients import Client [as 别名]
# 或者: from b3.clients.Client import save [as 别名]
def test_two_bans_with_reason(self):
# GIVEN
when(self.console).time().thenReturn(0)
player1 = Client(console=self.console, guid='player1GUID', name="P1")
player1.save()
penalty1 = ClientBan(clientId=player1.id, timeExpire=-1, adminId=0, reason="test reason")
player2 = Client(console=self.console, guid='player2GUID', name="P2")
player2.save()
penalty2 = ClientTempBan(clientId=player2.id, timeExpire=self.console.time() + 60*2, adminId=0, reason="test reason f00")
when(self.console.storage).getLastPenalties(types=whatever(), num=whatever()).thenReturn([penalty1, penalty2])
# WHEN
self.lastbans()
# THEN
self.mock_command.sayLoudOrPM.assert_has_calls([
call(self.player, u'^[email protected]^7 P1^7^7 (Perm) test reason'),
call(self.player, u'^[email protected]^7 P2^7^7 (2 minutes remaining) test reason f00'),
])
示例6: test_known_client__guid
# 需要导入模块: from b3.clients import Client [as 别名]
# 或者: from b3.clients.Client import save [as 别名]
def test_known_client__guid(self):
# GIVEN
known_client = Client(console=self.parser, guid="12312312312312312", name="courgette", connections=15)
known_client.save()
self.assertEqual(1, len(self.parser.clients))
self.assertDictContainsSubset({'clients': 2}, self.parser.storage.getCounts())
# WHEN
client = self.parser.getClientOrCreate(guid="12312312312312312", name="newName", team="0")
# THEN
self.assertIsInstance(client, Client)
self.assertEqual(known_client.id, client.id)
self.assertEqual("12312312312312312", client.cid)
self.assertEqual("12312312312312312", client.guid)
self.assertEqual("newName", client.name)
self.assertEqual(TEAM_SCAVENGERS, client.team)
self.assertEqual(16, client.connections)
self.assertTrue(client.authed)
self.assertEqual(2, len(self.parser.clients))
self.assertDictContainsSubset({'clients': 2}, self.parser.storage.getCounts())