Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_client(self, get_return=None, put_return=None, post_return=None, options_return=None, delete_return=None):
ex_resp = self._build_mock_response()
with patch('ox3apiclient.requests.Session') as mock_requests_session:
with patch('ox3apiclient.Client.log_request') as mock_client_log_request:
mock_requests_session.return_value.get.return_value = get_return or ex_resp
mock_requests_session.return_value.post.return_value = post_return or ex_resp
mock_requests_session.return_value.put.return_value = put_return or ex_resp
mock_requests_session.return_value.options.return_value = options_return or ex_resp
mock_requests_session.return_value.delete.return_value = delete_return or ex_resp
mock_client_log_request.return_value = None
return ox3apiclient.Client(
email=self.email,
password=self.password,
domain=self.domain,
realm=self.realm,
consumer_key=self.consumer_key,
consumer_secret=self.consumer_secret,
request_token_url=self.request_token_url,
access_token_url=self.access_token_url,
authorization_url=self.authorization_url)
def test_returns_client(self):
file_path = os.path.join(os.path.dirname(__file__), 'ox3rctest')
ox = ox3apiclient.client_from_file(file_path=file_path)
self.assertTrue(isinstance(ox, ox3apiclient.Client))
def test_logoff(self):
client = self._get_client()
ret_val = client.logoff()
self.assertTrue(isinstance(ret_val, ox3apiclient.Client))