diff --git a/backend/src/appenlight/__init__.py b/backend/src/appenlight/__init__.py index 62d32a3..3b46dcd 100644 --- a/backend/src/appenlight/__init__.py +++ b/backend/src/appenlight/__init__.py @@ -28,7 +28,7 @@ import appenlight.lib.encryption as encryption from pyramid.config import PHASE3_CONFIG from pyramid.authentication import AuthTktAuthenticationPolicy from pyramid.authorization import ACLAuthorizationPolicy -from pyramid_mailer.mailer import Mailer +from pyramid_mailer.interfaces import IMailer from pyramid.renderers import JSON from pyramid_redis_sessions import session_factory_from_settings from pyramid.settings import asbool, aslist @@ -143,6 +143,7 @@ def main(global_config, **settings): config.include('pyramid_redis_sessions') config.include('pyramid_tm') config.include('pyramid_jinja2') + config.include('pyramid_mailer') config.include('appenlight_client.ext.pyramid_tween') config.include('ziggurat_foundations.ext.pyramid.sign_in') es_server_list = aslist(settings['elasticsearch.nodes']) @@ -154,8 +155,8 @@ def main(global_config, **settings): config.registry.redis_lockmgr = Redlock([settings['redis.redlock.url'], ], retry_count=0, retry_delay=0) - # mailer - config.registry.mailer = Mailer.from_settings(settings) + # mailer bw compat + config.registry.mailer = config.registry.getUtility(IMailer) # Configure sessions session_factory = session_factory_from_settings(settings) diff --git a/backend/src/appenlight/tests/conftest.py b/backend/src/appenlight/tests/conftest.py index 3855f15..1801b24 100644 --- a/backend/src/appenlight/tests/conftest.py +++ b/backend/src/appenlight/tests/conftest.py @@ -27,11 +27,12 @@ from zope.sqlalchemy import mark_changed from pyramid.paster import get_appsettings from pyramid import testing -from appenlight.models import Base, DBSession - @pytest.fixture -def base_app(request): +def base_app(request, mocker): + # disable email sending + mocker.patch('pyramid_mailer.mailer_factory_from_settings', mocker.Mock()) + from appenlight import main import transaction current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -91,6 +92,8 @@ def default_data(base_app): @pytest.fixture def clean_tables(request): + from appenlight.models import Base, DBSession + def fin(): tables = Base.metadata.tables.keys() transaction.begin() @@ -106,6 +109,7 @@ def clean_tables(request): @pytest.fixture def default_user(): + from appenlight.models import DBSession from appenlight.models.user import User from appenlight.models.auth_token import AuthToken transaction.begin() @@ -124,6 +128,7 @@ def default_user(): @pytest.fixture def default_application(default_user): + from appenlight.models import DBSession from appenlight.models.application import Application transaction.begin()