本文整理汇总了Python中Tribler.Test.Core.base_test.MockObject.state方法的典型用法代码示例。如果您正苦于以下问题:Python MockObject.state方法的具体用法?Python MockObject.state怎么用?Python MockObject.state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Test.Core.base_test.MockObject
的用法示例。
在下文中一共展示了MockObject.state方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getters_setters_2
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import state [as 别名]
def test_getters_setters_2(self):
"""
Testing various getters and setters in DownloadState
"""
lt_status = MockObject()
lt_status.state = 3
lt_status.upload_rate = 123
lt_status.download_rate = 43
lt_status.total_upload = 100
lt_status.total_download = 200
lt_status.all_time_upload = 100
lt_status.all_time_download = 200
lt_status.list_peers = 10
lt_status.list_seeds = 5
lt_status.progress = 0.75
lt_status.error = False
lt_status.paused = False
lt_status.state = 3
lt_status.num_pieces = 0
lt_status.pieces = []
lt_status.finished_time = 10
download_state = DownloadState(self.mock_download, lt_status, None, {'vod_prebuf_frac_consec': 43,
'vod_prebuf_frac': 44})
self.assertEqual(download_state.get_status(), DLSTATUS_DOWNLOADING)
self.assertEqual(download_state.get_current_speed(UPLOAD), 123)
self.assertEqual(download_state.get_current_speed(DOWNLOAD), 43)
self.assertEqual(download_state.get_total_transferred(UPLOAD), 100)
self.assertEqual(download_state.get_total_transferred(DOWNLOAD), 200)
self.assertEqual(download_state.get_vod_prebuffering_progress_consec(), 43)
self.assertEqual(download_state.get_vod_prebuffering_progress(), 44)
self.assertTrue(download_state.is_vod())
self.assertEqual(download_state.get_seeding_ratio(), 0.5)
self.assertEqual(download_state.get_eta(), 0.25)
self.assertEqual(download_state.get_num_seeds_peers(), (5, 5))
self.assertEqual(download_state.get_pieces_complete(), [])
self.assertEqual(download_state.get_pieces_total_complete(), (0, 0))
self.assertEqual(download_state.get_seeding_time(), 10)
lt_status.num_pieces = 6
lt_status.pieces = [1, 1, 1, 0, 0, 0]
self.assertEqual(download_state.get_pieces_complete(), [1, 1, 1, 0, 0, 0])
self.assertEqual(download_state.get_pieces_total_complete(), (6, 3))
self.mock_download.get_selected_files = lambda: ['test']
self.assertEqual(download_state.get_selected_files(), ['test'])
self.assertEqual(download_state.get_progress(), 0.75)
示例2: test_get_circuits
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import state [as 别名]
def test_get_circuits(self):
"""
Testing whether the API returns the correct circuits
"""
mock_hop = MockObject()
mock_hop.host = 'somewhere'
mock_hop.port = 4242
mock_circuit = MockObject()
mock_circuit.state = 'TESTSTATE'
mock_circuit.goal_hops = 42
mock_circuit.bytes_up = 200
mock_circuit.bytes_down = 400
mock_circuit.creation_time = 1234
mock_circuit.hops = [mock_hop]
mock_circuit.peer = MockObject()
mock_circuit.peer.address = ("1.1.1.1", 1234)
mock_circuit.circuit_id = 1234
mock_circuit.ctype = CIRCUIT_TYPE_DATA
mock_circuit.destroy = lambda: None
self.session.lm.tunnel_community = MockObject()
self.session.lm.tunnel_community.circuits = {1234: mock_circuit}
def verify_response(response):
response_json = json.loads(response)
self.assertEqual(len(response_json['circuits']), 1)
self.assertEqual(response_json['circuits'][0]['state'], 'TESTSTATE')
self.assertEqual(response_json['circuits'][0]['bytes_up'], 200)
self.assertEqual(response_json['circuits'][0]['bytes_down'], 400)
self.assertEqual(len(response_json['circuits'][0]['hops']), 1)
self.assertEqual(response_json['circuits'][0]['hops'][0]['host'], 'somewhere:4242')
self.should_check_equality = False
return self.do_request('debug/circuits', expected_code=200).addCallback(verify_response)
示例3: create_mock_status
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import state [as 别名]
def create_mock_status(self):
status = MockObject()
status.state = 3
status.upload_rate = 123
status.download_rate = 43
status.upload_payload_rate = 123
status.download_payload_rate = 43
status.total_upload = 100
status.total_download = 200
status.all_time_upload = 100
status.all_time_download = 200
status.list_peers = 10
status.list_seeds = 5
status.progress = 0.75
status.error = False
status.paused = False
status.state = 3
status.num_pieces = 0
status.pieces = []
return status