mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
tests: Run on_commit hooks immediately in tornado_redirected_to_list.
Further commits will hook `send_event` calls to `on_commit` in some cases. This change will make it easier to test such situations. We don't need to actually capture the callbacks, because the events sent are already tested via the list in which they are captured by `tornado_redirected_to_list`.
This commit is contained in:
@@ -1280,7 +1280,13 @@ Output:
|
||||
# So explicitly change parameter name to 'notice' to work around this problem
|
||||
django_tornado_api.process_notification = lambda notice: lst.append(notice)
|
||||
|
||||
yield
|
||||
# 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.
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
yield
|
||||
|
||||
django_tornado_api.process_notification = real_event_queue_process_notification
|
||||
|
||||
|
||||
Reference in New Issue
Block a user