Best Python code snippet using localstack_python
default_network.py
Source:default_network.py
1# coding: utf-82from __future__ import unicode_literals3import time4import requests5from .network_interface import Network, NetworkResponse6class DefaultNetwork(Network):7 """Implementation of the network interface using the requests library."""8 def __init__(self):9 super(DefaultNetwork, self).__init__()10 self._session = requests.Session()11 def request(self, method, url, access_token, **kwargs):12 """Base class override.13 Make a network request using a requests.Session.14 """15 return DefaultNetworkResponse(self._session.request(method, url, **kwargs), access_token)16 def retry_after(self, delay, request_method, *args, **kwargs):17 """Base class override.18 Retry after sleeping for delay seconds.19 """20 time.sleep(delay)21 return request_method(*args, **kwargs)22class DefaultNetworkResponse(NetworkResponse):23 """Implementation of the network interface using the requests library."""24 def __init__(self, request_response, access_token_used):25 self._request_response = request_response26 self._access_token_used = access_token_used27 def json(self):28 """Base class override."""29 return self._request_response.json()30 @property31 def content(self):32 """Base class override."""33 return self._request_response.content34 @property35 def status_code(self):36 """Base class override."""37 return self._request_response.status_code38 @property39 def ok(self):40 """Base class override."""41 # pylint:disable=invalid-name42 return self._request_response.ok43 @property44 def headers(self):45 """Base class override."""46 return self._request_response.headers47 @property48 def response_as_stream(self):49 """Base class override."""50 return self._request_response.raw51 @property52 def access_token_used(self):53 """Base class override."""...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!