mirror of
https://github.com/Cian-H/invenio-theme-iform.git
synced 2026-02-06 01:03:25 +00:00
global: extension class to uppercase. (#105)
The extension class name is changed to uppercase.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
"""invenio module for TUGRAZ theme."""
|
||||
|
||||
from .ext import inveniothemetugraz
|
||||
from .ext import InvenioThemeTugraz
|
||||
from .version import __version__
|
||||
|
||||
__all__ = ('__version__', 'inveniothemetugraz')
|
||||
__all__ = ('__version__', 'InvenioThemeTugraz')
|
||||
|
||||
@@ -13,7 +13,7 @@ from flask_babelex import gettext as _
|
||||
from . import config
|
||||
|
||||
|
||||
class inveniothemetugraz(object):
|
||||
class InvenioThemeTugraz(object):
|
||||
"""invenio-theme-tugraz extension."""
|
||||
|
||||
def __init__(self, app=None):
|
||||
|
||||
2
setup.py
2
setup.py
@@ -79,7 +79,7 @@ setup(
|
||||
platforms='any',
|
||||
entry_points={
|
||||
'invenio_base.apps': [
|
||||
'invenio_theme_tugraz = invenio_theme_tugraz:inveniothemetugraz',
|
||||
'invenio_theme_tugraz = invenio_theme_tugraz:InvenioThemeTugraz',
|
||||
],
|
||||
'invenio_base.blueprints': [
|
||||
'invenio_theme_tugraz = invenio_theme_tugraz.views:blueprint',
|
||||
|
||||
@@ -12,31 +12,21 @@ See https://pytest-invenio.readthedocs.io/ for documentation on which test
|
||||
fixtures are available.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
from flask import Flask
|
||||
from flask_babelex import Babel
|
||||
from invenio_db import InvenioDB, db
|
||||
from invenio_i18n import InvenioI18N
|
||||
from invenio_search import InvenioSearch
|
||||
|
||||
from invenio_theme_tugraz import inveniothemetugraz
|
||||
from invenio_theme_tugraz import InvenioThemeTugraz
|
||||
from invenio_theme_tugraz.views import blueprint
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def app():
|
||||
"""Flask app fixture."""
|
||||
app = Flask('myapp')
|
||||
app.config.update(
|
||||
I18N_LANGUAGES=[('en', 'English'), ('de', 'German')],
|
||||
)
|
||||
Babel(app)
|
||||
InvenioI18N(app)
|
||||
app.register_blueprint(create_blueprint_from_app(app))
|
||||
return app
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def celery_config():
|
||||
"""Override pytest-invenio fixture.
|
||||
@@ -46,14 +36,37 @@ def celery_config():
|
||||
return {}
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def create_app(instance_path):
|
||||
"""Application factory fixture."""
|
||||
def factory(**config):
|
||||
app = Flask('testapp', instance_path=instance_path)
|
||||
app.config.update(**config)
|
||||
Babel(app)
|
||||
inveniothemetugraz(app)
|
||||
app.register_blueprint(blueprint)
|
||||
return app
|
||||
return factory
|
||||
@pytest.fixture()
|
||||
def app(request):
|
||||
"""Basic Flask application."""
|
||||
instance_path = tempfile.mkdtemp()
|
||||
app = Flask("testapp")
|
||||
DB = os.getenv("SQLALCHEMY_DATABASE_URI", "sqlite://")
|
||||
app.config.update(
|
||||
I18N_LANGUAGES=[('en', 'English'), ('de', 'German')],
|
||||
SQLALCHEMY_DATABASE_URI=DB,
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS=False,
|
||||
)
|
||||
Babel(app)
|
||||
InvenioDB(app)
|
||||
InvenioSearch(app)
|
||||
InvenioThemeTugraz(app)
|
||||
|
||||
with app.app_context():
|
||||
db_url = str(db.engine.url)
|
||||
if db_url != "sqlite://" and not database_exists(db_url):
|
||||
create_database(db_url)
|
||||
db.create_all()
|
||||
|
||||
def teardown():
|
||||
with app.app_context():
|
||||
db_url = str(db.engine.url)
|
||||
db.session.close()
|
||||
if db_url != "sqlite://":
|
||||
drop_database(db_url)
|
||||
shutil.rmtree(instance_path)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
app.test_request_context().push()
|
||||
|
||||
return app
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
from flask import Flask
|
||||
|
||||
from invenio_theme_tugraz import inveniothemetugraz
|
||||
from invenio_theme_tugraz import InvenioThemeTugraz
|
||||
|
||||
|
||||
def test_version():
|
||||
@@ -22,11 +22,16 @@ def test_version():
|
||||
def test_init():
|
||||
"""Test extension initialization."""
|
||||
app = Flask('testapp')
|
||||
ext = inveniothemetugraz(app)
|
||||
ext = InvenioThemeTugraz(app)
|
||||
assert 'invenio-theme-tugraz' in app.extensions
|
||||
|
||||
app = Flask('testapp')
|
||||
ext = inveniothemetugraz()
|
||||
ext = InvenioThemeTugraz()
|
||||
assert 'invenio-theme-tugraz' not in app.extensions
|
||||
ext.init_app(app)
|
||||
assert 'invenio-theme-tugraz' in app.extensions
|
||||
|
||||
|
||||
def test_app(app):
|
||||
"""Test extension initialization."""
|
||||
theme = InvenioThemeTugraz(app)
|
||||
|
||||
Reference in New Issue
Block a user