Skip to content

Commit

Permalink
test: fixes
Browse files Browse the repository at this point in the history
* move implicit use to explicit import

* adapt usage of changed invenio-userprofiles programmatic api

* remove unused import

* since the actual way to build the test app is not used, the finalize-app
  functions have to be executed manually. in this particular case the call of
  the finalize_app of invenio-userprofiles was missing.
  • Loading branch information
utnapischtim committed Mar 22, 2024
1 parent 41692f1 commit 9e1b149
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ install_requires =

[options.extras_require]
tests =
flask_admin>=1.6.0
pytest-black-ng>=0.4.0
httpretty>=0.8.14
invenio-userprofiles>=3.0.0
Expand Down
13 changes: 11 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
from invenio_db import InvenioDB, db
from invenio_i18n import Babel, InvenioI18N
from invenio_userprofiles import InvenioUserProfiles
from invenio_userprofiles.views import blueprint_ui_init
from invenio_userprofiles.ext import finalize_app as userprofiles_finalize_app
from invenio_userprofiles.views import create_blueprint
from sqlalchemy_utils.functions import create_database, database_exists, drop_database

from invenio_oauthclient import InvenioOAuthClient, InvenioOAuthClientREST
Expand Down Expand Up @@ -142,6 +143,7 @@ def base_app(request):
APP_THEME=["semantic-ui"],
THEME_ICONS={"semantic-ui": dict(link="linkify icon")},
OAUTHCLIENT_SETTINGS_TEMPLATE="invenio_oauthclient/settings/base.html",
USERPROFILES_EXTEND_SECURITY_FORMS=False,
)
FlaskMenu(base_app)
Babel(base_app)
Expand Down Expand Up @@ -182,6 +184,10 @@ def _init_app(app_):
InvenioOAuthClient(app_)
app_.register_blueprint(blueprint_client)
app_.register_blueprint(blueprint_settings)

with app_.app_context():
userprofiles_finalize_app(app_)

return app_


Expand Down Expand Up @@ -228,7 +234,10 @@ def app_rest_with_userprofiles(app_rest):
def _init_userprofiles(app_):
"""Init userprofiles module."""
InvenioUserProfiles(app_)
app_.register_blueprint(blueprint_ui_init)
app_.register_blueprint(create_blueprint(app_))

with app_.app_context():
userprofiles_finalize_app(app_)
return app_


Expand Down
3 changes: 1 addition & 2 deletions tests/test_handlers_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
#
# This file is part of Invenio.
# Copyright (C) 2016-2018 CERN.
# Copyright (C) 2024 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Test handlers."""

from turtle import pd

import pytest
from flask import session, url_for
from flask_login import current_user
Expand Down

0 comments on commit 9e1b149

Please sign in to comment.