本文整理汇总了Python中dht.crawling.NodeSpiderCrawl._nodesFound方法的典型用法代码示例。如果您正苦于以下问题:Python NodeSpiderCrawl._nodesFound方法的具体用法?Python NodeSpiderCrawl._nodesFound怎么用?Python NodeSpiderCrawl._nodesFound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dht.crawling.NodeSpiderCrawl
的用法示例。
在下文中一共展示了NodeSpiderCrawl._nodesFound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nodesFound
# 需要导入模块: from dht.crawling import NodeSpiderCrawl [as 别名]
# 或者: from dht.crawling.NodeSpiderCrawl import _nodesFound [as 别名]
def test_nodesFound(self):
self._connecting_to_connected()
self.wire_protocol[self.addr1] = self.con
self.wire_protocol[self.addr2] = self.con
self.wire_protocol[self.addr3] = self.con
self.protocol.router.addContact(self.node1)
self.protocol.router.addContact(self.node2)
self.protocol.router.addContact(self.node3)
node = Node(digest("s"))
nearest = self.protocol.router.findNeighbors(node)
spider = NodeSpiderCrawl(self.protocol, node, nearest, 20, 3)
response = (True, (self.node1.getProto().SerializeToString(), self.node2.getProto().SerializeToString(),
self.node3.getProto().SerializeToString()))
responses = {self.node1.id: response}
spider._nodesFound(responses)
self.clock.advance(constants.PACKET_TIMEOUT)
connection.REACTOR.runUntilCurrent()
self.assertEqual(len(self.proto_mock.send_datagram.call_args_list), 4)
response = (True, (self.node1.getProto().SerializeToString(), self.node2.getProto().SerializeToString(),
self.node3.getProto().SerializeToString()))
responses = {self.node1.id: response}
nodes = spider._nodesFound(responses)
node_protos = []
for n in nodes:
node_protos.append(n.getProto())
self.assertTrue(self.node1.getProto() in node_protos)
self.assertTrue(self.node2.getProto() in node_protos)
self.assertTrue(self.node3.getProto() in node_protos)
response = (False, (self.node1.getProto().SerializeToString(), self.node2.getProto().SerializeToString(),
self.node3.getProto().SerializeToString()))
responses = {self.node1.id: response}
nodes = spider._nodesFound(responses)
node_protos = []
for n in nodes:
node_protos.append(n.getProto())
self.assertTrue(self.node2.getProto() in node_protos)
self.assertTrue(self.node3.getProto() in node_protos)