def verify(repeated, operational, non_operational, unverified): """Verify if the servers are operational.""" if operational: operational = True elif non_operational: operational = False try: verify_all(repeated, operational, unverified) except KeyboardInterrupt: log.warning("CTRL+C detected! exiting.") sys.exit(0)
def test_success(self, ms): create_cwd(cwd()) socks5 = mock.MagicMock() socks5.host = "8.8.8.8" socks5.port = 4242 ms.return_value = socks5 self.db.add_socks5("8.8.8.8", 4242, "Germany", "DE") verify_all() socks5.verify.assert_called_once() socks5.measure_connection_time.assert_called_once() socks5.approx_bandwidth.assert_not_called()
def test_bandwidth(self, ms): create_cwd(cwd()) socks5 = mock.MagicMock() socks5.host = "8.8.8.8" socks5.port = 4242 ms.return_value = socks5 self.db.add_socks5("8.8.8.8", 4242, "Germany", "DE") Config._cache["bandwidth"]["enabled"] = True verify_all() socks5.verify.assert_called_once() socks5.measure_connection_time.assert_called_once() socks5.approx_bandwidth.assert_called_once() Config._cache["bandwidth"]["enabled"] = False
def test_download_verify_fail(self, ms, mu): create_cwd(cwd()) socks5 = mock.MagicMock() socks5.host = "8.8.8.8" socks5.port = 4242 ms.return_value = socks5 mu.side_effect = socket.error self.db.add_socks5("8.8.8.8", 4242, "Germany", "DE") Config._cache["bandwidth"]["enabled"] = True verify_all() socks5.verify.assert_called_once() socks5.measure_connection_time.assert_called_once() mu.assert_called_once_with(mock.ANY, timeout=5) socks5.approx_bandwidth.assert_not_called() Config._cache["bandwidth"]["enabled"] = False