Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_client_init_with_credentials():
Client('XXX', 'XXX')
return self.request('DELETE', *args, **kwargs)
def request(self, *args, **kwargs):
if not self.expected:
raise ValueError('did not expect any requests, received %s, %s' % (args, kwargs))
exp = self.expected.pop(0)
res = self.returned.pop(0)
if exp != (args, kwargs):
raise ValueError('expected:\n %s\nreceived:\n %s' % (exp, (args, kwargs)))
return res
class SpyClient(Client):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._session = SpySession()
def force_authenticate(self):
# just fill the _auth variable with something that has an access token
self._auth = {'access_token': 'XXX'}
def expect(client, *args, **kwargs):
# add implicit access_token if we are given an authenticated client
if client._auth:
if 'params' not in kwargs:
kwargs['params'] = {}
kwargs['params']['access_token'] = 'XXX'