本文整理汇总了Python中Tribler.Test.Core.base_test.MockObject.peer方法的典型用法代码示例。如果您正苦于以下问题:Python MockObject.peer方法的具体用法?Python MockObject.peer怎么用?Python MockObject.peer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Test.Core.base_test.MockObject
的用法示例。
在下文中一共展示了MockObject.peer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_circuits
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import peer [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)