From 1c0fb0a9600e93a5e33b5977af4f7684c06e470c Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Mon, 20 Apr 2026 17:35:06 +0200 Subject: [PATCH] src/auth/routes.py : blueprint auth et fixtures de test (#73) Co-Authored-By: Claude Sonnet 4.6 --- src/auth/routes.py | 3 +++ src/auth/setup.py | 4 ++++ tests/auth/conftest.py | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/auth/routes.py diff --git a/src/auth/routes.py b/src/auth/routes.py new file mode 100644 index 0000000..63de288 --- /dev/null +++ b/src/auth/routes.py @@ -0,0 +1,3 @@ +from flask import Blueprint + +auth_bp = Blueprint("auth", __name__, url_prefix="/auth") diff --git a/src/auth/setup.py b/src/auth/setup.py index adf621b..bf16502 100644 --- a/src/auth/setup.py +++ b/src/auth/setup.py @@ -43,6 +43,10 @@ def init_auth(app: Flask) -> None: _login_manager.user_loader(load_user) _login_manager.init_app(app) + from src.auth.routes import auth_bp + + app.register_blueprint(auth_bp) + _csrf = CSRFProtect(app) if not os.getenv("SMTP_HOST"): diff --git a/tests/auth/conftest.py b/tests/auth/conftest.py index ce77c3b..ee11048 100644 --- a/tests/auth/conftest.py +++ b/tests/auth/conftest.py @@ -10,3 +10,26 @@ def users_db_path(monkeypatch, tmp_path): reset_conn_for_tests() yield db_path reset_conn_for_tests() + + +@pytest.fixture +def app(users_db_path, monkeypatch): + from flask import Flask + + from src.auth.setup import init_auth + + app = Flask(__name__) + init_auth(app) + yield app + + +@pytest.fixture +def client(app): + return app.test_client() + + +@pytest.fixture +def mail_outbox(app): + mail = app.extensions["mail"] + with mail.record_messages() as outbox: + yield outbox