def test_acquire_countrycode(self): for c in ["DE", "CA", "NL"]: self.db.add_socks5( "8.8.8.8", 1337, "Unknown", c, city="Unknown", operational=True, username="******", password="******", description="Such wow, many socks5" ) m = Manager() socks5_1 = m.acquire(country_code="ca") assert socks5_1.id == 2 assert socks5_1.country_code == "CA" socks5_2 = m.acquire(country_code="FR") assert socks5_2 is None
def test_acquire_city(self): for c in ["Dogedown", "Amsterdam", "Tallinn"]: self.db.add_socks5( "8.8.8.8", 1337, "Unknown", "Unknown", city=c, operational=True, username="******", password="******", description="Such wow, many socks5" ) m = Manager() socks5_1 = m.acquire(city="tallinn") assert socks5_1.id == 3 assert socks5_1.city == "Tallinn" socks5_2 = m.acquire(city="Nowhere") assert socks5_2 is None
def test_acquire_country(self): for c in ["United States", "China", "Germany"]: self.db.add_socks5( "8.8.8.8", 1337, c, "Unknown", city="Unknown", operational=True, username="******", password="******", description="Such wow, many socks5" ) m = Manager() socks5_1 = m.acquire(country="germany") assert socks5_1.id == 3 assert socks5_1.country == "Germany" socks5_2 = m.acquire(country="france") assert socks5_2 is None
def test_acquire_mbps(self): for c in ["DE", "CA", "NL", "NL", "PL"]: self.db.add_socks5( "8.8.8.8", 1337, "Unknown", c, city="Unknown", operational=True, username="******", password="******", description="Such wow, many socks5" ) self.db.set_approx_bandwidth(2, 5.33) self.db.set_approx_bandwidth(3, 19.811) self.db.set_approx_bandwidth(4, 7.134) self.db.set_approx_bandwidth(5, 28.134) m = Manager() socks5_1 = m.acquire(min_mbps_down=4) socks5_2 = m.acquire(min_mbps_down=4, country_code="nl") socks5_3 = m.acquire(min_mbps_down=1, country_code="de") assert socks5_1.id == 5 assert socks5_2.id == 3 assert socks5_3 is None
def test_acquire(self): past = datetime.datetime.now() for c in ["United States", "China", "Germany"]: self.db.add_socks5( "8.8.8.8", 1337, c, "Unknown", city="Unknown", operational=True, username="******", password="******", description="Such wow, many socks5" ) m = Manager() socks5_1 = m.acquire() socks5_2 = m.acquire() socks5_3 = m.acquire() socks5_4 = m.acquire() assert socks5_1.id == 1 assert socks5_1.last_use > past assert socks5_2.id == 2 assert socks5_2.last_use > past assert socks5_3.id == 3 assert socks5_3.last_use > past assert socks5_4.id == 1 assert socks5_4.last_use > socks5_1.last_use
def test_acquire_conntime(self): for c in ["DE", "CA", "NL", "NL", "PL"]: self.db.add_socks5( "8.8.8.8", 1337, "Unknown", c, city="Unknown", operational=True, username="******", password="******", description="Such wow, many socks5" ) self.db.set_connect_time(2, 0.02) self.db.set_connect_time(3, 0.1) self.db.set_connect_time(4, 0.0054) self.db.set_connect_time(5, 1.3) m = Manager() socks5_1 = m.acquire(max_connect_time=0.01) socks5_2 = m.acquire(max_connect_time=0.2, country_code="nl") socks5_3 = m.acquire(max_connect_time=0.5, country_code="pl") socks5_4 = m.acquire(max_connect_time=0.0001) assert socks5_1.id == 4 assert socks5_2.id == 3 assert socks5_3 is None assert socks5_4 is None
def test_acquire_no_operational(self): self.db.add_socks5( "8.8.8.8", 1337, "germany", "Unknown", city="Unknown", operational=False, username="******", password="******", description="Such wow, many socks5" ) self.db.add_socks5( "8.8.8.8", 1337, "china", "Unknown", city="Unknown", operational=False, username="******", password="******", description="Such wow, many socks5" ) m = Manager() socks5_1 = m.acquire() assert socks5_1 is None socks5_2 = m.acquire(country="china") assert socks5_2 is None self.db.add_socks5( "8.8.8.8", 1337, "france", "Unknown", city="Unknown", operational=True, username="******", password="******", description="Such wow, many socks5" ) socks5_3 = m.acquire() assert socks5_3.id == 3