本文整理汇总了Python中b3.fake.FakeClient.var方法的典型用法代码示例。如果您正苦于以下问题:Python FakeClient.var方法的具体用法?Python FakeClient.var怎么用?Python FakeClient.var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b3.fake.FakeClient
的用法示例。
在下文中一共展示了FakeClient.var方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Test_events
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import var [as 别名]
class Test_events(JumperTestCase):
def setUp(self):
JumperTestCase.setUp(self)
with logging_disabled():
from b3.fake import FakeClient
# create some clients
self.mike = FakeClient(console=self.console, name="Mike", guid="mikeguid", team=TEAM_FREE, groupBits=1)
self.bill = FakeClient(console=self.console, name="Bill", guid="billguid", team=TEAM_FREE, groupBits=1)
self.mike.connects("1")
self.bill.connects("2")
# force fake mapname
self.console.game.mapName = 'ut42_bstjumps_u2'
def tearDown(self):
self.mike.disconnects()
self.bill.disconnects()
JumperTestCase.tearDown(self)
####################################################################################################################
# #
# JUMPRUN EVENTS #
# #
####################################################################################################################
def test_event_client_jumprun_started(self):
# WHEN
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.mike, data={'way_id' : '1'}))
# THEN
self.assertEqual(True, self.mike.isvar(self.p, 'jumprun'))
self.assertIsNone(self.mike.var(self.p, 'jumprun').value.demo)
self.assertIsInstance(self.mike.var(self.p, 'jumprun').value, JumpRun)
def test_event_client_jumprun_stopped(self):
# WHEN
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.mike, data={'way_id' : '1', 'way_time' : '12345'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertListEqual([], self.p.getClientRecords(self.mike, self.console.game.mapName))
def test_event_client_jumprun_canceled(self):
# WHEN
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_CANCEL', client=self.mike, data={'way_id' : '1'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertListEqual([], self.p.getClientRecords(self.mike, self.console.game.mapName))
def test_event_client_jumprun_started_stopped(self):
# WHEN
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.mike, data={'way_id' : '1'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.mike, data={'way_id' : '1', 'way_time' : '12345'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertEqual(1, len(self.p.getClientRecords(self.mike, self.console.game.mapName)))
def test_event_client_jumprun_started_canceled(self):
# WHEN
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.mike, data={'way_id' : '1'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_CANCEL', client=self.mike, data={'way_id' : '1'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertEqual(0, len(self.p.getClientRecords(self.mike, self.console.game.mapName)))
def test_event_client_jumprun_started_stopped_multiple_clients(self):
# WHEN
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.mike, data={'way_id' : '1'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.mike, data={'way_id' : '1', 'way_time' : '12345'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.bill, data={'way_id' : '1'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.bill, data={'way_id' : '1', 'way_time' : '12345'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertEqual(False, self.bill.isvar(self.p, 'jumprun'))
self.assertEqual(1, len(self.p.getClientRecords(self.mike, self.console.game.mapName)))
self.assertEqual(1, len(self.p.getClientRecords(self.bill, self.console.game.mapName)))
def test_event_client_jumprun_started_stopped_multiple_ways(self):
# WHEN
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.mike, data={'way_id' : '1'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.mike, data={'way_id' : '1', 'way_time' : '12345'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.mike, data={'way_id' : '2'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.mike, data={'way_id' : '2', 'way_time' : '12345'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertEqual(2, len(self.p.getClientRecords(self.mike, self.console.game.mapName)))
def test_event_client_jumprun_started_stopped_multiple_clients_multiple_ways(self):
# WHEN
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.mike, data={'way_id' : '1'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.mike, data={'way_id' : '1', 'way_time' : '12345'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.mike, data={'way_id' : '2'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.mike, data={'way_id' : '2', 'way_time' : '12345'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.bill, data={'way_id' : '1'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.bill, data={'way_id' : '1', 'way_time' : '12345'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_START', client=self.bill, data={'way_id' : '2'}))
self.console.queueEvent(self.console.getEvent('EVT_CLIENT_JUMP_RUN_STOP', client=self.bill, data={'way_id' : '2', 'way_time' : '12345'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertEqual(False, self.bill.isvar(self.p, 'jumprun'))
#.........这里部分代码省略.........
示例2: Test_events
# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import var [as 别名]
class Test_events(JumperTestCase):
def setUp(self):
JumperTestCase.setUp(self)
with logging_disabled():
from b3.fake import FakeClient
# prevent the test to query the api: we handle this somewhere else
when(self.p).getMapsData().thenReturn(dict())
# create some clients
self.mike = FakeClient(console=self.console, name="Mike", guid="mikeguid", team=TEAM_FREE, groupBits=1)
self.bill = FakeClient(console=self.console, name="Bill", guid="billguid", team=TEAM_FREE, groupBits=1)
self.mike.connects("1")
self.bill.connects("2")
# force fake mapname
self.console.game.mapName = 'ut42_bstjumps_u2'
def tearDown(self):
self.mike.disconnects()
self.bill.disconnects()
JumperTestCase.tearDown(self)
####################################################################################################################
## ##
## JUMPRUN EVENTS ##
## ##
####################################################################################################################
def test_event_client_jumprun_started(self):
# WHEN
event = self.console.getEventID('EVT_CLIENT_JUMP_RUN_START')
self.console.queueEvent(Event(event, client=self.mike, data={'way_id' : '1'}))
# THEN
self.assertEqual(True, self.mike.isvar(self.p, 'jumprun'))
self.assertIsNone(self.mike.var(self.p, 'jumprun').value.demo)
self.assertIsInstance(self.mike.var(self.p, 'jumprun').value, JumpRun)
def test_event_client_jumprun_stopped(self):
# WHEN
event = self.console.getEventID('EVT_CLIENT_JUMP_RUN_STOP')
self.console.queueEvent(Event(event, client=self.mike, data={'way_id' : '1', 'way_time' : '12345'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertListEqual([], self.p.getClientRecords(self.mike, self.console.game.mapName))
def test_event_client_jumprun_canceled(self):
# WHEN
event = self.console.getEventID('EVT_CLIENT_JUMP_RUN_CANCEL')
self.console.queueEvent(Event(event, client=self.mike, data={'way_id' : '1'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertListEqual([], self.p.getClientRecords(self.mike, self.console.game.mapName))
def test_event_client_jumprun_started_stopped(self):
# WHEN
event1 = self.console.getEventID('EVT_CLIENT_JUMP_RUN_START')
event2 = self.console.getEventID('EVT_CLIENT_JUMP_RUN_STOP')
self.console.queueEvent(Event(event1, client=self.mike, data={'way_id' : '1'}))
self.console.queueEvent(Event(event2, client=self.mike, data={'way_id' : '1', 'way_time' : '12345'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertEqual(1, len(self.p.getClientRecords(self.mike, self.console.game.mapName)))
def test_event_client_jumprun_started_canceled(self):
# WHEN
event1 = self.console.getEventID('EVT_CLIENT_JUMP_RUN_START')
event2 = self.console.getEventID('EVT_CLIENT_JUMP_RUN_CANCEL')
self.console.queueEvent(Event(event1, client=self.mike, data={'way_id' : '1'}))
self.console.queueEvent(Event(event2, client=self.mike, data={'way_id' : '1'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertEqual(0, len(self.p.getClientRecords(self.mike, self.console.game.mapName)))
def test_event_client_jumprun_started_stopped_multiple_clients(self):
# WHEN
event1 = self.console.getEventID('EVT_CLIENT_JUMP_RUN_START')
event2 = self.console.getEventID('EVT_CLIENT_JUMP_RUN_STOP')
self.console.queueEvent(Event(event1, client=self.mike, data={'way_id' : '1'}))
self.console.queueEvent(Event(event2, client=self.mike, data={'way_id' : '1', 'way_time' : '12345'}))
self.console.queueEvent(Event(event1, client=self.bill, data={'way_id' : '1'}))
self.console.queueEvent(Event(event2, client=self.bill, data={'way_id' : '1', 'way_time' : '12345'}))
# THEN
self.assertEqual(False, self.mike.isvar(self.p, 'jumprun'))
self.assertEqual(False, self.bill.isvar(self.p, 'jumprun'))
self.assertEqual(1, len(self.p.getClientRecords(self.mike, self.console.game.mapName)))
self.assertEqual(1, len(self.p.getClientRecords(self.bill, self.console.game.mapName)))
def test_event_client_jumprun_started_stopped_multiple_ways(self):
# WHEN
event1 = self.console.getEventID('EVT_CLIENT_JUMP_RUN_START')
event2 = self.console.getEventID('EVT_CLIENT_JUMP_RUN_STOP')
self.console.queueEvent(Event(event1, client=self.mike, data={'way_id' : '1'}))
self.console.queueEvent(Event(event2, client=self.mike, data={'way_id' : '1', 'way_time' : '12345'}))
self.console.queueEvent(Event(event1, client=self.mike, data={'way_id' : '2'}))
self.console.queueEvent(Event(event2, client=self.mike, data={'way_id' : '2', 'way_time' : '12345'}))
# THEN
#.........这里部分代码省略.........