-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes a crash application when the invenio user does not have email address and is not a library user (patron or librarian). * Clears the user name session when the user is logged out. Co-Authored-by: Johnny Mariéthoz <[email protected]>
- Loading branch information
Showing
4 changed files
with
88 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,55 @@ | |
"""Common pytest fixtures and plugins.""" | ||
|
||
|
||
from datetime import datetime | ||
|
||
import pytest | ||
from invenio_accounts.ext import hash_password | ||
from invenio_accounts.models import User | ||
from invenio_search import current_search_client | ||
|
||
|
||
@pytest.fixture(scope='function') | ||
def user_with_profile(db): | ||
"""Create a simple invenio user with a profile.""" | ||
with db.session.begin_nested(): | ||
user = User( | ||
email='[email protected]', | ||
password=hash_password('123456'), | ||
profile=dict(), active=True) | ||
db.session.add(user) | ||
profile = user.profile | ||
profile.birth_date = datetime(1990, 1, 1) | ||
profile.first_name = 'User' | ||
profile.last_name = 'With Profile' | ||
profile.city = 'Nowhere' | ||
profile.username = 'user_with_profile' | ||
db.session.merge(user) | ||
db.session.commit() | ||
user.password_plaintext = '123456' | ||
return user | ||
|
||
|
||
@pytest.fixture(scope='function') | ||
def user_without_email(db): | ||
"""Create a simple invenio user without email.""" | ||
with db.session.begin_nested(): | ||
user = User( | ||
password=hash_password('123456'), | ||
profile=dict(), active=True) | ||
db.session.add(user) | ||
profile = user.profile | ||
profile.birth_date = datetime(1990, 1, 1) | ||
profile.first_name = 'User' | ||
profile.last_name = 'With Profile' | ||
profile.city = 'Nowhere' | ||
profile.username = 'user_without_email' | ||
db.session.merge(user) | ||
db.session.commit() | ||
user.password_plaintext = '123456' | ||
return user | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def create_app(): | ||
"""Create test app.""" | ||
|
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