def test_http_unprocessed_infohashes(self): session = HttpTrackerSession("localhost", ("localhost", 8475), "/announce", 5) result_deferred = Deferred() session.result_deferred = result_deferred session._infohash_list.append("test") response = bencode({"files": {"a" * 20: {"complete": 10, "incomplete": 10}}}) session._process_scrape_response(response) self.assertTrue(session.is_finished)
def test_http_unprocessed_infohashes(self): session = HttpTrackerSession("localhost", ("localhost", 8475), "/announce", 5) result_deffered = Deferred() session.result_deferred = result_deffered session._infohash_list.append("test") response = bencode(dict()) session._process_scrape_response(response) self.assertTrue(session.is_finished)
def test_http_unprocessed_infohashes(self): session = HttpTrackerSession("localhost", ("localhost", 8475), "/announce", 5) result_deffered = Deferred() session.result_deferred = result_deffered session._infohash_list.append("test") response = bencode(dict()) session._process_scrape_response(response) self.assertTrue(session.is_finished)
def test_failed_unicode(self): test_deferred = Deferred() session = HttpTrackerSession(u"localhost", ("localhost", 8475), "/announce", 5) def on_error(failure): self.assertEqual(failure.type, ValueError) test_deferred.callback(None) session.result_deferred = Deferred().addErrback(on_error) session._process_scrape_response(bencode({'failure reason': '\xe9'})) return test_deferred
def test_httpsession_failure_reason_in_dict(self): session = HttpTrackerSession("localhost", ("localhost", 8475), "/announce", 5) session._infohash_list = [] session._process_scrape_response(bencode({'failure reason': 'test'})) self.assertTrue(session.is_failed)
def test_httpsession_bdecode_fails(self): session = HttpTrackerSession("localhost", ("localhost", 8475), "/announce", 5) session._infohash_list = [] session._process_scrape_response("test") self.assertTrue(session.is_failed)
def test_httpsession_failure_reason_in_dict(self): session = HttpTrackerSession("localhost", ("localhost", 8475), "/announce", 5) session._infohash_list = [] session._process_scrape_response(bencode({'failure reason': 'test'})) self.assertTrue(session.is_failed)
def test_httpsession_bdecode_fails(self): session = HttpTrackerSession("localhost", ("localhost", 8475), "/announce", 5) session._infohash_list = [] session._process_scrape_response(bencode({})) self.assertTrue(session.is_failed)
def test_httpsession_scrape_no_body(self): session = HttpTrackerSession("localhost", ("localhost", 8475), "/announce", 5) session._process_scrape_response(None) session._infohash_list = [] self.assertTrue(session.is_failed)