コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
from flaskr.configuration import Configuration
from flaskr.flask_application import Application

application = Application.init_app(Configuration)
app = application.flask_application
コード例 #4
0
 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
コード例 #5
0
from flaskr.flask_application import Application
from tests.configuration.configuration_test import TestConfiguration

application = Application.init_app(TestConfiguration)
app = application.flask_application
コード例 #6
0
 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()
コード例 #7
0
 def decorator(test_item):
     Application.init_app(TestConfiguration)
     return test_item
コード例 #8
0
 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)
コード例 #9
0
 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)