Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InstalledAppFlow #128

Merged
merged 7 commits into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
Jon Wayne Parrott committed Mar 22, 2017
commit d464f865b082adb01be8d4f7e99b33d5f896c09c
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