From c0927c718d3df81d11f63ba8dcddde26e0bb8f0b Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Wed, 24 Jun 2026 15:35:23 +0200 Subject: [PATCH] =?UTF-8?q?test(brevo):=20test=20d'int=C3=A9gration=20sand?= =?UTF-8?q?box=20optionnel=20(#87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- pyproject.toml | 3 +++ tests/auth/test_mailer_integration.py | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/auth/test_mailer_integration.py diff --git a/pyproject.toml b/pyproject.toml index e8a2dc8..cf4e569 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,3 +62,6 @@ env = [ "DATA_SCHEMA_LOCAL=/home/colin/git/decp-processing/dist/schema.json", ] addopts = "-p no:warnings" +markers = [ + "integration: tests touchant des services externes (Brevo) ; skippés par défaut en CI", +] diff --git a/tests/auth/test_mailer_integration.py b/tests/auth/test_mailer_integration.py new file mode 100644 index 0000000..05bd7c8 --- /dev/null +++ b/tests/auth/test_mailer_integration.py @@ -0,0 +1,22 @@ +import os + +import pytest + +from src.auth import mailer + +pytestmark = pytest.mark.integration + + +@pytest.mark.skipif( + not os.getenv("BREVO_API_KEY"), + reason="BREVO_API_KEY absent — test d'intégration Brevo ignoré", +) +def test_send_verification_email_sandbox(monkeypatch): + # Force le mode sandbox : Brevo valide la requête sans délivrer. + monkeypatch.setenv("BREVO_SANDBOX", "true") + monkeypatch.setenv("APP_BASE_URL", "http://localhost:8050") + mailer.init_mailer() + # Ne doit pas lever : l'API Brevo accepte la requête en sandbox. + mailer.send_verification_email( + os.getenv("MAIL_FROM", "noreply@decp.info"), "INTEGRATION_TOKEN" + )