def test_replace_trackers(self) -> None: # list of announce_entry ae = lt.announce_entry("http://127.1.2.3") ae.tier = 2 ae.fail_limit = 3 self.handle.replace_trackers([ae]) # list of dicts entry_dict = {"url": "http://127.1.2.3", "tier": 2, "fail_limit": 3} self.assertEqual( [self.get_input_entry(ae) for ae in self.handle.trackers()], [entry_dict] )
def test_replace_trackers(self): self.setup() trackers = [] for idx, tracker_url in enumerate(('udp://tracker1.com', 'udp://tracker2.com')): tracker = lt.announce_entry(tracker_url) tracker.tier = idx tracker.fail_limit = 2 trackers.append(tracker) self.h.replace_trackers(trackers) new_trackers = self.h.trackers() self.assertEqual(new_trackers[0]['url'], 'udp://tracker1.com') self.assertEqual(new_trackers[1]['tier'], 1) self.assertEqual(new_trackers[1]['fail_limit'], 2)
def test_pickle_trackers(self): """Test lt objects convertors are working and trackers can be pickled""" self.setup() tracker = lt.announce_entry('udp://tracker1.com') tracker.tier = 0 tracker.fail_limit = 1 trackers = [tracker] self.h.replace_trackers(trackers) tracker_list = [tracker for tracker in self.h.trackers()] pickled_trackers = pickle.dumps(tracker_list) unpickled_trackers = pickle.loads(pickled_trackers) self.assertEqual(unpickled_trackers[0]['url'], 'udp://tracker1.com') self.assertEqual(unpickled_trackers[0]['last_error']['value'], 0)
def test_pickle_trackers(self): """Test lt objects convertors are working and trackers can be pickled""" self.setup() tracker = lt.announce_entry('udp://tracker1.com') tracker.tier = 0 tracker.fail_limit = 1 trackers = [tracker] self.h.replace_trackers(trackers) # wait a bit until the endpoints list gets populated while len(self.h.trackers()[0]['endpoints']) == 0: time.sleep(0.1) pickled_trackers = pickle.dumps(self.h.trackers()) unpickled_trackers = pickle.loads(pickled_trackers) self.assertEqual(unpickled_trackers[0]['url'], 'udp://tracker1.com') self.assertEqual(unpickled_trackers[0]['endpoints'][0]['last_error']['value'], 0)
def test_pickle_trackers(self): """Test lt objects convertors are working and trackers can be pickled""" self.setup() tracker = lt.announce_entry('udp://tracker1.com') tracker.tier = 0 tracker.fail_limit = 1 trackers = [tracker] self.h.replace_trackers(trackers) # wait a bit until the endpoints list gets populated while len(self.h.trackers()[0]['endpoints']) == 0: time.sleep(0.1) trackers = self.h.trackers() self.assertEqual(trackers[0]['url'], 'udp://tracker1.com') # this is not necessarily 0, it could also be (EHOSTUNREACH) if the # local machine doesn't support the address family expect_value = trackers[0]['endpoints'][0]['info_hashes'][0]['last_error']['value'] pickled_trackers = pickle.dumps(trackers) unpickled_trackers = pickle.loads(pickled_trackers) self.assertEqual(unpickled_trackers[0]['url'], 'udp://tracker1.com') self.assertEqual(unpickled_trackers[0]['endpoints'][0]['info_hashes'][0]['last_error']['value'], expect_value)
def test_announce_entry(self): ae = lt.announce_entry('test') self.assertEquals(ae.url, 'test') self.assertEquals(ae.tier, 0) self.assertEquals(ae.verified, False) self.assertEquals(ae.source, 0)
def test_announce_entry(self): ae = lt.announce_entry('test') self.assertEquals(ae.can_announce(False), True) self.assertEquals(ae.scrape_incomplete, -1) self.assertEquals(ae.next_announce, None) self.assertEquals(ae.last_error.value(), 0)