本文整理汇总了Python中twisted.python.failure.Failure.tracker_url方法的典型用法代码示例。如果您正苦于以下问题:Python Failure.tracker_url方法的具体用法?Python Failure.tracker_url怎么用?Python Failure.tracker_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.failure.Failure
的用法示例。
在下文中一共展示了Failure.tracker_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_on_health_check_completed
# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import tracker_url [as 别名]
def test_on_health_check_completed(self):
tracker1 = 'udp://localhost:2801'
tracker2 = "http://badtracker.org/announce"
infohash_bin = '\xee'*20
infohash_hex = hexlify(infohash_bin)
self.session.lm.popularity_community.queue_content = lambda _: None
failure = Failure()
failure.tracker_url = tracker2
result = [
(True, {tracker1: [{'leechers': 1, 'seeders': 2, 'infohash': infohash_hex}]}),
(False, failure),
(True, {'DHT': [{'leechers': 12, 'seeders': 13, 'infohash': infohash_hex}]})
]
# Check that everything works fine even if the database contains no proper infohash
res_dict = {
'DHT': {
'leechers': 12,
'seeders': 13,
'infohash': infohash_hex
},
'http://badtracker.org/announce': {
'error': ''
},
'udp://localhost:2801': {
'leechers': 1,
'seeders': 2,
'infohash': infohash_hex
}
}
self.torrent_checker.on_torrent_health_check_completed(infohash_bin, result)
self.assertDictEqual(self.torrent_checker.on_torrent_health_check_completed(infohash_bin, result), res_dict)
self.assertFalse(self.torrent_checker.on_torrent_health_check_completed(infohash_bin, None))
with db_session:
ts = self.session.lm.mds.TorrentState(infohash=infohash_bin)
previous_check = ts.last_check
self.torrent_checker.on_torrent_health_check_completed(infohash_bin, result)
self.assertEqual(result[2][1]['DHT'][0]['leechers'], ts.leechers)
self.assertEqual(result[2][1]['DHT'][0]['seeders'], ts.seeders)
self.assertLess(previous_check, ts.last_check)