def has_connection(): # In case we run tests in an environment without internet connection. try: HttpStream("https://httpbin.org/get", "get") return True except OsbsNetworkException: return False
def has_connection(): # In case we run tests in an environment without internet connection. try: HttpStream("https://httpbin.org/get", "get", retries_enabled=False) return True except (OsbsNetworkException, requests.exceptions.ConnectionError): return False
def test_set_timeout(self): url = "http://httpbin.org/get" method = "get" kwargs = {'allow_redirects': True, 'headers': {}} fake_response = flexmock(status_code=http_client.OK, headers={}) (flexmock(requests.Session).should_receive('request').with_args( method, url, timeout=HTTP_REQUEST_TIMEOUT, verify=False, **kwargs).and_return(fake_response).once()) HttpStream(url, method, verify_ssl=False, **kwargs)
def has_connection(): # In case we run tests in an environment without internet connection. if sys.version_info < (2, 7): # py 2.6 doesn't have SNI support, required for httpbin, as it has SSLv3 certificates return False try: HttpStream("https://httpbin.org/get", "get") return True except OsbsNetworkException: return False