async def test_udpsession_correct_handle(self): session = UdpTrackerSession("localhost", ("localhost", 4782), "/announce", 5, self.socket_mgr) session.ip_address = "127.0.0.1" session.infohash_list.append(b'test') self.socket_mgr.response = struct.pack("!iiq", 0, session.transaction_id, 2) await session.connect() self.socket_mgr.response = struct.pack("!iiiii", 2, session.transaction_id, 0, 1, 2) await session.scrape() self.assertFalse(session.is_failed) await session.cleanup()
async def test_udpsession_correct_handle(fake_udp_socket_manager): session = UdpTrackerSession("localhost", ("localhost", 4782), "/announce", 5, None, fake_udp_socket_manager) session.ip_address = "127.0.0.1" session.infohash_list.append(b'test') fake_udp_socket_manager.response = struct.pack("!iiq", 0, session.transaction_id, 2) await session.connect() fake_udp_socket_manager.response = struct.pack("!iiiii", 2, session.transaction_id, 0, 1, 2) await session.scrape() assert not session.is_failed await session.cleanup()