当前位置: 首页>>代码示例>>Python>>正文


Python Piece.not_all_blocks_requested方法代码示例

本文整理汇总了Python中piece.Piece.not_all_blocks_requested方法的典型用法代码示例。如果您正苦于以下问题:Python Piece.not_all_blocks_requested方法的具体用法?Python Piece.not_all_blocks_requested怎么用?Python Piece.not_all_blocks_requested使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在piece.Piece的用法示例。


在下文中一共展示了Piece.not_all_blocks_requested方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_piece_one_block

# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import not_all_blocks_requested [as 别名]
 def test_piece_one_block(self):
     piece = Piece(fake_client, 1, 2**14, 'abc', test_dir)
     self.assertEqual(piece.num_blocks, 1)
     self.assertTrue(piece.not_all_blocks_requested()) 
     block_info = piece.get_next_block()
     self.assertEqual(block_info[0], 1)
     self.assertEqual(block_info[1], 0)
     self.assertEqual(block_info[2], 2**14)
     self.assertFalse(piece.not_all_blocks_requested())
开发者ID:wevial,项目名称:downpour,代码行数:11,代码来源:piece_test.py

示例2: test_piece_two_blocks

# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import not_all_blocks_requested [as 别名]
 def test_piece_two_blocks(self):
     piece = Piece(fake_client, 1, 2**14 + 2, 'abcd', test_dir)
     self.assertEqual(piece.num_blocks, 2)
     self.assertTrue(piece.not_all_blocks_requested()) 
     block = piece.get_next_block()
     self.assertTrue(piece.not_all_blocks_requested())
     block = piece.get_next_block()
     self.assertEqual(block[1], 2**14, '2nd block should begin at byte 2**14')
     self.assertEqual(block[2], 2, '2nd block should have length 2')
     self.assertFalse(piece.not_all_blocks_requested())
开发者ID:wevial,项目名称:downpour,代码行数:12,代码来源:piece_test.py

示例3: test_piece_one_short_block

# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import not_all_blocks_requested [as 别名]
 def test_piece_one_short_block(self):
     piece = Piece(fake_client, 1, 2, 'abcd', test_dir)
     self.assertEqual(piece.num_blocks, 1)
     self.assertTrue(piece.not_all_blocks_requested()) 
     block = piece.get_next_block()
     self.assertEqual(block[2], 2)
     (block_info, peer) = piece.get_next_block_and_peer_to_request()
     self.assertEqual(peer, None)
     self.assertEqual(block_info[0], 1)
     self.assertEqual(block_info[1], 0)
     self.assertEqual(block_info[2], 2**14)
     self.assertFalse(piece.not_all_blocks_requested())
开发者ID:wevial,项目名称:downpour,代码行数:14,代码来源:piece_test.py

示例4: test_piece_info_hash

# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import not_all_blocks_requested [as 别名]
 def test_piece_info_hash(self):
     test_bytes = '\x00\x01\x02'
     test_hash = hashlib.sha1(test_bytes).digest()
     piece = Piece(fake_client, 1, 3, test_hash, test_dir)
     piece.write_file = StringIO()
     self.assertEqual(piece.num_blocks, 1)
     self.assertFalse(piece.check_if_finished())
     self.assertTrue(piece.not_all_blocks_requested())
     piece.add_block(0, test_bytes)
     self.assertTrue(piece.check_if_finished())
     self.assertTrue(piece.check_info_hash())
开发者ID:wevial,项目名称:downpour,代码行数:13,代码来源:piece_test.py


注:本文中的piece.Piece.not_all_blocks_requested方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。