def test_should_return_an_instance_of_app_with_configuration(self): class TestConfiguration(Configuration): ENV = "TEST" SQLALCHEMY_DATABASE_URI = "" application = Application.init_app(TestConfiguration) env = application.configuration_value_for("ENV") self.assertEqual("TEST", env)
def wrapper(*args, **kargs): from flaskr.flask_application import Application authorization_header = request.headers.get("x-api-key", "") x_api_key = Application.instance().configuration_value_for("X_API_KEY") if authorization_header == "" or authorization_header != x_api_key: abort(401) return func(*args, **kargs)
from flaskr.configuration import Configuration from flaskr.flask_application import Application application = Application.init_app(Configuration) app = application.flask_application
def migration_manager(self) -> Manager: app = Application.init_app(self.__config).flask_application Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) return manager
from flaskr.flask_application import Application from tests.configuration.configuration_test import TestConfiguration application = Application.init_app(TestConfiguration) app = application.flask_application
def __init__(self): from flaskr.flask_application import Application from flaskr.logger_factory import LoggerFactory self.api_key = Application.instance().configuration_value_for( "OMDB_API_KEY") self.logger = LoggerFactory.instance().logger()
def decorator(test_item): Application.init_app(TestConfiguration) return test_item
def test_should_return_an_instance_of_app_with_db_reference(self): application = Application.init_app(TestConfiguration) app = application.db self.assertTrue(type(app) == SQLAlchemy)
def test_should_return_an_instance_of_app_with_api_reference(self): application = Application.init_app(TestConfiguration) api = application.api self.assertTrue(type(api) == Api)