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" + )