From 1bf1ebdb663cf160cface903bf5458a631220b4e Mon Sep 17 00:00:00 2001 From: Brian Pepple Date: Sat, 17 Oct 2026 08:55:36 -0400 Subject: [PATCH] Stop tests from sending real Pushover notifications Some users view tests went through signup and account activation without mocking send_pushover, so every test run sent real notifications to my phone. Add an autouse block_pushover fixture in tests/conftest.py that patches send_pushover where it's imported (users.utils, users.views and the sync_opencollective_donors and notify_throttled_clients commands). Tests that check Pushover calls still apply their own patch, which takes precedence. --- tests/conftest.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 2d2151d4..f66ecaa3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,6 +34,20 @@ def run_cache_bumps_immediately(): yield +@pytest.fixture(autouse=True) +def block_pushover(): + """Never send real Pushover notifications from tests. Callers import + send_pushover by name, so each import site is patched; tests that assert on + it re-patch the same target, and the inner patch takes precedence.""" + with ( + patch("users.utils.send_pushover"), + patch("users.views.send_pushover"), + patch("users.management.commands.sync_opencollective_donors.send_pushover"), + patch("api.management.commands.notify_throttled_clients.send_pushover"), + ): + yield + + @pytest.fixture(autouse=True) def isolated_login_throttle(): """Give each test its own failed-login counters. Tests share the real Redis