diff --git a/bodhi-server/tests/conftest.py b/bodhi-server/tests/conftest.py index 177bb73295..239c471345 100644 --- a/bodhi-server/tests/conftest.py +++ b/bodhi-server/tests/conftest.py @@ -33,6 +33,21 @@ def mock_settings_env_vars(): yield +@pytest.fixture(autouse=True) +def always_fail_publish(): + """ + Make sure any attempt to actually publish a message during a test + fails, by mocking out the 'real' message publishing function in + fedora_messaging. If you hit this exception, it means you need to + use mock_sends, or (if for some reason mock_sends isn't a good + fit), mock out notifications.publish or + notifications._publish_with_retry. + """ + with mock.patch("fedora_messaging.api._twisted_publish", + side_effect=ValueError("Non-mocked message publish attempted!")): + yield + + @pytest.fixture(scope="session") def critpath_json_config(request): """