Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott committed Mar 22, 2017
1 parent 2c2d5af commit d464f86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@
import wsgiref.simple_server
import wsgiref.util

from six.moves import input

import google.auth.transport.requests
import google.oauth2.credentials
from six.moves import input

import google_auth_oauthlib.helpers

Expand Down Expand Up @@ -281,7 +280,7 @@ class InstalledAppFlow(Flow):
Example::
from google.oauth2.flow import InstalledAppFlow
from google_auth_oauthlib.flow import InstalledAppFlow
flow = InstalledAppFlow.from_client_secrets_file(
'client_secrets.json',
Expand Down
10 changes: 5 additions & 5 deletions additional_packages/google_auth_oauthlib/tests/test_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,21 @@ def set_token(*args, **kwargs):
with fetch_token_patch as fetch_token_mock:
yield fetch_token_mock

@mock.patch('google.oauth2.flow.input', autospec=True)
@mock.patch('google_auth_oauthlib.flow.input', autospec=True)
def test_run_console(self, input_mock, instance, mock_fetch_token):
input_mock.return_value = mock.sentinel.code

credentials = instance.run_console()

assert credentials.token == mock.sentinel.access_token
assert credentials.refresh_token == mock.sentinel.refresh_token
assert credentials._refresh_token == mock.sentinel.refresh_token

mock_fetch_token.assert_called_with(
CLIENT_SECRETS_INFO['web']['token_uri'],
client_secret=CLIENT_SECRETS_INFO['web']['client_secret'],
code=mock.sentinel.code)

@mock.patch('google.oauth2.flow.webbrowser', autospec=True)
@mock.patch('google_auth_oauthlib.flow.webbrowser', autospec=True)
def test_run_local_server(
self, webbrowser_mock, instance, mock_fetch_token):
auth_redirect_url = urllib.parse.urljoin(
Expand All @@ -179,7 +179,7 @@ def test_run_local_server(
credentials = future.result()

assert credentials.token == mock.sentinel.access_token
assert credentials.refresh_token == mock.sentinel.refresh_token
assert credentials._refresh_token == mock.sentinel.refresh_token
assert webbrowser_mock.open.called

expected_auth_response = auth_redirect_url.replace('http', 'https')
Expand All @@ -188,7 +188,7 @@ def test_run_local_server(
client_secret=CLIENT_SECRETS_INFO['web']['client_secret'],
authorization_response=expected_auth_response)

@mock.patch('google.oauth2.flow.webbrowser', autospec=True)
@mock.patch('google_auth_oauthlib.flow.webbrowser', autospec=True)
@mock.patch('wsgiref.simple_server.make_server', autospec=True)
def test_run_local_server_no_browser(
self, make_server_mock, webbrowser_mock, instance,
Expand Down

0 comments on commit d464f86

Please sign in to comment.