def test_equality(self): fields = torrent.TorrentFields._ALL_FIELDS from random import shuffle for _ in range(10): f1 = list(fields) ; shuffle(f1) f2 = list(fields) ; shuffle(f2) self.assertEqual(torrent.TorrentFields(*f1), torrent.TorrentFields(*f2))
def test_handpicked_fields(self): testcase = ('id', 'hash', 'name', 'status', 'id', 'id', 'id') expect = ('id', 'hashString', 'name', 'status', 'percentDone', 'metadataPercentComplete', 'rateDownload', 'rateUpload', 'peersConnected', 'trackerStats', 'isPrivate') self.assertEqual(sorted(torrent.TorrentFields(*testcase)), sorted(expect))
def test_adding(self): f1 = torrent.TorrentFields('name', 'stalled') f2 = torrent.TorrentFields('name', 'ratio') f3 = torrent.TorrentFields('hash', 'status') self.assertEqual(f1+f2, torrent.TorrentFields('name', 'stalled', 'ratio')) self.assertEqual(f1+f3, torrent.TorrentFields('name', 'stalled', 'hash', 'status')) self.assertEqual(f2+f3, torrent.TorrentFields('name', 'ratio', 'hash', 'status')) self.assertEqual(f1+f2+f3, torrent.TorrentFields('name', 'stalled', 'ratio', 'hash', 'status'))
def test_preset_all(self): self.assertEqual(sorted(torrent.TorrentFields('all')), sorted(torrent.TorrentFields._ALL_FIELDS))
def test_handpicked_fields(self): testcase = ('id', 'hash', 'name', 'isolated', 'id', 'id', 'id') expect = ('id', 'hashString', 'name', 'isPrivate', 'trackerStats') self.assertEqual(sorted(torrent.TorrentFields(*testcase)), sorted(expect))