mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
django_api: Rename 'send_event' to 'send_event_rollback_unsafe'.
This commit renames the 'send_event' function to 'send_event_rollback_unsafe' to reflect the fact that it doesn't wait for the db transaction (within which it gets called, if any) to commit and sends event irrespective of commit or rollback. In most of the cases we don't want to send event in the case of rollbacks, so the caller should be aware that calling the function directly is rollback unsafe.
This commit is contained in:
committed by
Tim Abbott
parent
8e71806958
commit
e763d065a3
@@ -2052,11 +2052,11 @@ 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` 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` calls actually run.
|
||||
# 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.
|
||||
self.captureOnCommitCallbacks(execute=True),
|
||||
):
|
||||
yield lst
|
||||
|
||||
Reference in New Issue
Block a user