@mock.patch('changes.web.auth.OAuth2WebServerFlow.step2_exchange')
def test_simple(self, step2_exchange):
    access_token = ('b' * 40)
    refresh_token = ('c' * 40)
    step2_exchange.return_value = OAuth2Credentials(access_token, current_app.config['GOOGLE_CLIENT_ID'], current_app.config['GOOGLE_CLIENT_SECRET'], refresh_token, datetime(2013, 9, 19, 22, 15, 22), GOOGLE_TOKEN_URI, 'foo/1.0', revoke_uri=GOOGLE_REVOKE_URI, id_token={'hd': 'example.com', 'email': 'example@example.com'})
    resp = self.client.get('/auth/complete/?code=abc')
    step2_exchange.assert_called_once_with('abc')
    assert (resp.status_code == 302)
    assert (resp.headers['Location'] == 'http://localhost/?finished_login=success')
    user = User.query.filter((User.email == 'example@example.com')).first()
    assert user
@mock.patch('changes.web.auth.OAuth2WebServerFlow.step2_exchange')
def test_simple(self, step2_exchange):
    access_token = ('b' * 40)
    refresh_token = ('c' * 40)
    step2_exchange.return_value = OAuth2Credentials(access_token, current_app.config['GOOGLE_CLIENT_ID'], current_app.config['GOOGLE_CLIENT_SECRET'], refresh_token, datetime(2013, 9, 19, 22, 15, 22), GOOGLE_TOKEN_URI, 'foo/1.0', revoke_uri=GOOGLE_REVOKE_URI, id_token={'hd': 'example.com', 'email': 'example@example.com'})
    resp = self.client.get('/auth/complete/?code=abc')
    step2_exchange.assert_called_once_with('abc')
    assert (resp.status_code == 302)
    assert (resp.headers['Location'] == 'http://localhost/?finished_login=success')
    user = User.query.filter((User.email == 'example@example.com')).first()
    assert user