Address review comments. To be squashed.

This commit is contained in:
Danny Hermes
2016-08-02 16:36:53 -07:00
parent 256d48dab8
commit 1a70341761
4 changed files with 10 additions and 7 deletions

View File

@@ -229,8 +229,8 @@ class FlaskOAuth2Tests(unittest2.TestCase):
with mock.patch( with mock.patch(
'oauth2client.transport.get_http_object') as new_http: 'oauth2client.transport.get_http_object') as new_http:
# Set-up mock. # Set-up mock.
new_http.return_value = http = http_mock.HttpMock( http = http_mock.HttpMock(data=DEFAULT_RESP)
data=DEFAULT_RESP) new_http.return_value = http
# Run tests. # Run tests.
state = self._setup_callback_state(client) state = self._setup_callback_state(client)

View File

@@ -32,9 +32,9 @@ EXPECTED_KWARGS = dict(headers=_metadata.METADATA_HEADERS)
def request_mock(status, content_type, content): def request_mock(status, content_type, content):
resp = http_mock.ResponseMock( response = http_mock.ResponseMock(
{'status': status, 'content-type': content_type}) {'status': status, 'content-type': content_type})
return mock.Mock(return_value=(resp, content.encode('utf-8'))) return mock.Mock(return_value=(response, content.encode('utf-8')))
class TestMetadata(unittest2.TestCase): class TestMetadata(unittest2.TestCase):

View File

@@ -15,6 +15,9 @@
"""HTTP helpers mock functionality.""" """HTTP helpers mock functionality."""
from six.moves import http_client
class ResponseMock(dict): class ResponseMock(dict):
"""Mock HTTP response""" """Mock HTTP response"""
@@ -22,7 +25,7 @@ class ResponseMock(dict):
if vals is None: if vals is None:
vals = {} vals = {}
self.update(vals) self.update(vals)
self.status = int(self.get('status', 200)) self.status = int(self.get('status', http_client.OK))
class HttpMock(object): class HttpMock(object):
@@ -35,7 +38,7 @@ class HttpMock(object):
headers: dict, header to return with response headers: dict, header to return with response
""" """
if headers is None: if headers is None:
headers = {'status': '200'} headers = {'status': http_client.OK}
self.data = data self.data = data
self.response_headers = headers self.response_headers = headers
self.headers = None self.headers = None

View File

@@ -908,7 +908,7 @@ class BasicCredentialsTests(unittest2.TestCase):
self.assertEqual(token_response, self.credentials.token_response) self.assertEqual(token_response, self.credentials.token_response)
def test_recursive_authorize(self): def test_recursive_authorize(self):
# Tests that OAuth2Credentials doesn't intro. new method constraints. # Tests that OAuth2Credentials doesn't introduce new method constraints.
# Formerly, OAuth2Credentials.authorize monkeypatched the request method # Formerly, OAuth2Credentials.authorize monkeypatched the request method
# of the passed in HTTP object with a wrapper annotated with # of the passed in HTTP object with a wrapper annotated with
# @util.positional(1). Since the original method has no such annotation, # @util.positional(1). Since the original method has no such annotation,