docs: Tweak some documentation around send_event.

This commit is contained in:
Tim Abbott
2024-09-20 15:28:18 -07:00
parent a7f48e260c
commit 51d0dfb504
4 changed files with 27 additions and 13 deletions

View File

@@ -2052,11 +2052,18 @@ class ZulipTestCase(ZulipTestCaseMixin, TestCase):
# So explicitly change parameter name to 'notice' to work around this problem
with (
mock.patch("zerver.tornado.event_queue.process_notification", lst.append),
# Some `send_event_rollback_unsafe` calls need to be executed only after the
# current transaction commits (using `on_commit` hooks). Because the transaction
# in Django tests never commits (rather, gets rolled back after the test completes),
# such events would never be sent in tests, and we would be unable to verify them.
# Hence, we use this helper to make sure the `send_event_rollback_unsafe` calls actually run.
# Some `send_event_rollback_unsafe` calls need to be
# executed only after the current transaction commits
# (mainly those using the `send_event_on_commit` wrapper, which
# sends the actual event inside an `on_commit` hook).
#
# Because the outer transaction in Django tests never
# commits (it gets rolled back when the test completes
# to restore the database to the desired state for the
# next test), such events would never be sent in
# tests, and we would be unable to verify them.
# Hence, we use this helper to make sure the
# `send_event_rollback_unsafe` calls actually run.
self.captureOnCommitCallbacks(execute=True),
):
yield lst