Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
* the problem is that the normal app creation process is not used. this custom
  app creation process needs a little bit love to work with the changes.

* since the menu is created in Menu InvenioTheme is not necessary anymore.

* the finalize_app call needs the app_context

* NOTE: this has to be refactored!!
  • Loading branch information
utnapischtim committed Mar 22, 2024
1 parent df4372c commit 171c5bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ tests =
pytest-black-ng>=0.4.0
pytest-invenio>=1.4.7
invenio-db[mysql,postgresql,versioning]>=1.0.14
invenio-app>=1.4.0
sphinx>=4.5
admin =
# empty for backward compatibility
Expand Down
5 changes: 2 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from invenio_assets import InvenioAssets
from invenio_db import InvenioDB, db
from invenio_i18n import Babel, InvenioI18N
from invenio_theme import InvenioTheme
from sqlalchemy_utils.functions import create_database, database_exists, drop_database

from invenio_userprofiles import InvenioUserProfiles
Expand Down Expand Up @@ -95,7 +94,6 @@ def base_app(app_config):
InvenioDB(base_app)
InvenioAccounts(base_app)
InvenioI18N(base_app)
InvenioTheme(base_app)
InvenioAssets(base_app)
base_app.register_blueprint(create_accounts_blueprint(base_app))

Expand Down Expand Up @@ -138,7 +136,8 @@ def _init_userprofiles_app(app_):
"""Init UserProfiles modules."""
InvenioUserProfiles(app_)
app_.register_blueprint(create_blueprint(app_))
finalize_app(app_)
with app_.app_context():
finalize_app(app_)
return app_


Expand Down
4 changes: 3 additions & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2022 Northwestern University.
# 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.
Expand Down Expand Up @@ -32,7 +33,8 @@ def test_profile_in_registration(base_app):
base_app.config.update(USERPROFILES_EXTEND_SECURITY_FORMS=True)
InvenioUserProfiles(base_app)
base_app.register_blueprint(create_blueprint(base_app))
finalize_app(base_app)
with base_app.app_context():
finalize_app(base_app)
app = base_app

with app.test_request_context():
Expand Down

0 comments on commit 171c5bf

Please sign in to comment.