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_authorize_token(self):
# mock the post response, and do some setup
r = self._build_mock_response()
r.text = 'oauth_verifier=verifier'
r.return_value = {'key': 'key', 'secret': 'secret'}
client = self._get_client(post_return=r)
client._token = {'key': 'key', 'secret': 'secret'}
# Unauthorized Case
r.status_code = 401
with self.assertRaises(ox3apiclient.OAuthException):
client.authorize_token()
# Authorized Case
r.status_code = 200
client.authorize_token()
self.assertEqual(client._token['verifier'], 'verifier')