當前位置: 首頁>>代碼示例>>Python>>正文


Python Client.save方法代碼示例

本文整理匯總了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))
開發者ID:ghostmod,項目名稱:big-brother-bot,代碼行數:28,代碼來源:test_bf3.py

示例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)
開發者ID:HaoDrang,項目名稱:big-brother-bot,代碼行數:34,代碼來源:test_Client.py

示例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')
開發者ID:BradyBrenot,項目名稱:big-brother-bot,代碼行數:12,代碼來源:test_admin.py

示例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())
開發者ID:ghostmod,項目名稱:big-brother-bot,代碼行數:20,代碼來源:test_csgo.py

示例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'),
        ])
開發者ID:BradyBrenot,項目名稱:big-brother-bot,代碼行數:21,代碼來源:test_admin.py

示例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())
開發者ID:BradyBrenot,項目名稱:big-brother-bot,代碼行數:21,代碼來源:test_ravaged.py


注:本文中的b3.clients.Client.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。