def test_attach_handlers(): app = Flask(__name__) attach_handlers(app, settings) before_funcs = app.before_request_funcs[None] after_funcs = app.after_request_funcs[None] teardown_funcs = app.teardown_request_funcs[None] assert_before_funcs = { framework.django.handlers.reset_django_db_queries_and_close_connections, framework.celery_tasks.handlers.celery_before_request, framework.transactions.handlers.transaction_before_request, framework.postcommit_tasks.handlers.postcommit_before_request, framework.sessions.prepare_private_key, framework.sessions.before_request, } assert_after_funcs = { framework.django.handlers.close_old_django_db_connections, framework.postcommit_tasks.handlers.postcommit_after_request, framework.celery_tasks.handlers.celery_after_request, framework.transactions.handlers.transaction_after_request, framework.sessions.after_request, } assert_teardown_funcs = { framework.django.handlers.close_old_django_db_connections, framework.celery_tasks.handlers.celery_teardown_request, framework.transactions.handlers.transaction_teardown_request, } # Check that necessary handlers are attached and correctly ordered assert_equal(sorted(set(before_funcs)), sorted(assert_before_funcs)) assert_equal(sorted(set(after_funcs)), sorted(assert_after_funcs)) assert_equal(sorted(set(teardown_funcs)), sorted(assert_teardown_funcs))
def test_attach_handlers(): app = Flask(__name__) attach_handlers(app, settings) before_funcs = app.before_request_funcs[None] after_funcs = app.after_request_funcs[None] teardown_funcs = app.teardown_request_funcs[None] assert_before_funcs = { framework.mongo.handlers.connection_before_request, framework.celery_tasks.handlers.celery_before_request, framework.transactions.handlers.transaction_before_request, framework.postcommit_tasks.handlers.postcommit_before_request, framework.sessions.prepare_private_key, framework.sessions.before_request, } assert_after_funcs = { framework.postcommit_tasks.handlers.postcommit_after_request, framework.celery_tasks.handlers.celery_after_request, framework.transactions.handlers.transaction_after_request, framework.sessions.after_request, } assert_teardown_funcs = { framework.mongo.handlers.connection_teardown_request, framework.celery_tasks.handlers.celery_teardown_request, framework.transactions.handlers.transaction_teardown_request, } # Check that necessary handlers are attached and correctly ordered assert_equal(sorted(set(before_funcs)), sorted(assert_before_funcs)) assert_equal(sorted(set(after_funcs)), sorted(assert_after_funcs)) assert_equal(sorted(set(teardown_funcs)), sorted(assert_teardown_funcs))
def init_app(): from framework.flask import app try: make_url_map(app) except AssertionError: pass init_addons(website_settings) attach_handlers(app, website_settings) for addon in website_settings.ADDONS_AVAILABLE: try: addon.ready() except AssertionError: pass return app
def test_attach_handlers(): app = Flask(__name__) attach_handlers(app, settings) before_funcs = app.before_request_funcs[None] # Check that necessary handlers are attached assert_in(framework.sessions.prepare_private_key, before_funcs) assert_in(framework.sessions.before_request, before_funcs) assert_in(framework.transactions.handlers.transaction_before_request, before_funcs) # Check that the order is correct assert_before(before_funcs, framework.sessions.prepare_private_key, framework.sessions.before_request) assert_before(before_funcs, framework.transactions.handlers.transaction_before_request, framework.sessions.prepare_private_key)
def test_attach_handlers(): app = Flask(__name__) attach_handlers(app, settings) before_funcs = app.before_request_funcs[None] # Check that necessary handlers are attached assert_in(framework.sessions.prepare_private_key, before_funcs) assert_in(framework.sessions.before_request, before_funcs) assert_in(framework.transactions.handlers.transaction_before_request, before_funcs) # Check that the order is correct assert_before(before_funcs, framework.sessions.prepare_private_key, framework.sessions.before_request) assert_before( before_funcs, framework.transactions.handlers.transaction_before_request, framework.sessions.prepare_private_key )
def test_attach_handlers(): app = Flask(__name__) attach_handlers(app, settings) before_funcs = app.before_request_funcs[None] after_funcs = app.after_request_funcs[None] teardown_funcs = app.teardown_request_funcs[None] assert_before_funcs = { framework.django.handlers. reset_django_db_queries_and_close_connections, framework.celery_tasks.handlers.celery_before_request, framework.transactions.handlers.transaction_before_request, framework.postcommit_tasks.handlers.postcommit_before_request, framework.sessions.prepare_private_key, framework.sessions.before_request, framework.csrf.handlers.before_request, } assert_after_funcs = { framework.django.handlers.close_old_django_db_connections, framework.postcommit_tasks.handlers.postcommit_after_request, framework.celery_tasks.handlers.celery_after_request, framework.transactions.handlers.transaction_after_request, framework.sessions.after_request, framework.csrf.handlers.after_request, } assert_teardown_funcs = { framework.django.handlers.close_old_django_db_connections, framework.celery_tasks.handlers.celery_teardown_request, framework.transactions.handlers.transaction_teardown_request, } # Check that necessary handlers are attached and correctly ordered assert_equal(set(before_funcs), assert_before_funcs) assert_equal(set(after_funcs), assert_after_funcs) assert_equal(set(teardown_funcs), assert_teardown_funcs)