-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
global: fix tests from pallets family upgrade
Co-authored-by: Zacharias Zacharodimos <[email protected]>
- Loading branch information
Showing
12 changed files
with
60 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,8 +76,7 @@ def test_authorized_signup_valid_user(app, example_globus): | |
remote_app='globus', code='test', | ||
state=_get_state())) | ||
assert resp.status_code == 302 | ||
assert resp.location == ('http://localhost/account/settings/' + | ||
'linkedaccounts/') | ||
assert resp.location == '/account/settings/linkedaccounts/' | ||
|
||
# Assert database state (Sign-up complete) | ||
user = User.query.filter_by(email='[email protected]').one() | ||
|
@@ -120,10 +119,7 @@ def test_authorized_signup_valid_user(app, example_globus): | |
remote_app='globus', code='test', | ||
state=_get_state())) | ||
assert resp.status_code == 302 | ||
assert resp.location == ( | ||
'http://localhost/' + | ||
'account/settings/linkedaccounts/' | ||
) | ||
assert resp.location == '/account/settings/linkedaccounts/' | ||
|
||
# check that exist only one account | ||
user = User.query.filter_by(email='[email protected]').one() | ||
|
@@ -140,9 +136,7 @@ def test_authorized_reject(app): | |
error_description='User denied access', | ||
state=_get_state())) | ||
assert resp.status_code in (301, 302) | ||
assert resp.location == ( | ||
'http://localhost/' | ||
) | ||
assert resp.location == '/' | ||
# Check message flash | ||
assert session['_flashes'][0][0] == 'info' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,41 +190,42 @@ def test_dummy_handler(remote_name, base_app): | |
|
||
|
||
@pytest.mark.parametrize('remote_name', REMOTE_APPS) | ||
def test_response_handler(remote_name, app_rest): | ||
def test_response_handler(remote_name, base_app): | ||
"""Test response handler.""" | ||
|
||
def mock_response_handler(remote, url, payload): | ||
return remote.name | ||
# Force usage of dummy handlers | ||
app_rest.config['OAUTHCLIENT_REST_REMOTE_APPS'][remote_name][ | ||
base_app.config['OAUTHCLIENT_REST_REMOTE_APPS'][remote_name][ | ||
'response_handler'] = mock_response_handler | ||
|
||
# Initialize InvenioOAuth | ||
FlaskOAuth(app_rest) | ||
InvenioOAuthClientREST(app_rest) | ||
app_rest.register_blueprint(rest_blueprint) | ||
FlaskOAuth(base_app) | ||
InvenioOAuthClientREST(base_app) | ||
base_app.register_blueprint(rest_blueprint) | ||
|
||
# Try to sign-up client | ||
response = app_rest.test_client().get( | ||
response = base_app.test_client().get( | ||
url_for('invenio_oauthclient.rest_signup', remote_app=remote_name) | ||
) | ||
assert remote_name in str(response.data) | ||
|
||
|
||
@pytest.mark.parametrize('remote', REMOTE_APPS, indirect=["remote"]) | ||
def test_response_handler_with_postmessage(remote, app_rest, models_fixture): | ||
def test_response_handler_with_postmessage(remote, base_app): | ||
"""Test response handler with postmessage.""" | ||
|
||
# Force usage of dummy handlers | ||
app_rest.config['OAUTHCLIENT_REST_REMOTE_APPS'][remote.name][ | ||
base_app.config['OAUTHCLIENT_REST_REMOTE_APPS'][remote.name][ | ||
'response_handler'] = response_handler_postmessage | ||
|
||
# Initialize InvenioOAuth | ||
FlaskOAuth(app_rest) | ||
InvenioOAuthClientREST(app_rest) | ||
app_rest.register_blueprint(rest_blueprint) | ||
FlaskOAuth(base_app) | ||
InvenioOAuthClientREST(base_app) | ||
# The `rest_blueprint` is already registered indirectly by the | ||
# `remote` fixture | ||
|
||
datastore = app_rest.extensions['invenio-accounts'].datastore | ||
datastore = base_app.extensions['invenio-accounts'].datastore | ||
existing_email = '[email protected]' | ||
user = datastore.find_user(email=existing_email) | ||
# Already authenticated | ||
|