global: migrate setup.py to setup.cfg

This commit is contained in:
Christoph Ladurner
2022-05-09 13:57:10 +02:00
committed by Mojib Wali
parent d8c91df396
commit 4fd0501c58
15 changed files with 83 additions and 279 deletions

View File

@@ -12,62 +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 sqlalchemy_utils.functions import create_database, database_exists, drop_database
from invenio_theme_tugraz import InvenioThemeTugraz
@pytest.fixture(scope="module")
def celery_config():
"""Override pytest-invenio fixture.
TODO: Remove this fixture if you add Celery support.
"""
return {}
@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)
InvenioI18N(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

View File

@@ -35,4 +35,4 @@ def test_init():
def test_app(app):
"""Test extension initialization."""
theme = InvenioThemeTugraz(app)
_ = InvenioThemeTugraz(app)

View File

@@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020-2021 Graz University of Technology.
#
# invenio-theme-tugraz is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
"""Pytest configuration.
See https://pytest-invenio.readthedocs.io/ for documentation on which test
fixtures are available.
"""
import pytest
from invenio_app.factory import create_ui
@pytest.fixture(scope='module')
def create_app(instance_path):
"""Application factory fixture."""
return create_ui

View File

@@ -1,33 +0,0 @@
# # -*- coding: utf-8 -*-
# #
# # Copyright (C) 2020-2021 Graz University of Technology.
# #
# # invenio-theme-tugraz 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 views."""
# from elasticsearch_dsl.utils import AttrDict
# from invenio_theme_tugraz.views import cast_to_dict, make_dict_like
# def test_make_dict_like():
# """Test make_dict_like."""
# access = {
# "access_right" : "open"
# }
# dicts = make_dict_like("open", "access_right")
# assert access == dicts
# def test_cast_to_dict():
# """Test cast_to_dict."""
# resource_type = {
# "subtype" : "publication-datamanagementplan",
# "type" : "publication"
# }
# expected = {'subtype': 'publication-datamanagementplan', 'type': 'publication'}
# attr = cast_to_dict(AttrDict(resource_type))
# assert expected == attr