Skip to content

Commit

Permalink
test_events: Run on_commit send_event hooks immediately.
Browse files Browse the repository at this point in the history
Further commits will hook some `send_event` calls to `on_commit`.
With those changes, these will never be executed in tests, because
transactions never get commited with `TestCase`, which the
`ZulipTestCase` is a subclass of.

We want to make sure that these events are actually sent for testing
purposes, hence this change.

There's no need to actually capture the callbacks, because the
events are already thoroughly tested.
  • Loading branch information
abhijeetbodas2001 committed Jun 4, 2021
1 parent 60464a4 commit 51f5bbc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion zerver/tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,13 @@ def verify_action(
include_subscribers=include_subscribers,
include_streams=include_streams,
)
action()

# We want even those `send_event` calls which have been hooked to
# `transaction.on_commit` to execute in tests.
# See the comment in `ZulipTestCase.tornado_redirected_to_list`.
with self.captureOnCommitCallbacks(execute=True):
action()

events = client.event_queue.contents()
content = {
"queue_id": "123.12",
Expand Down

0 comments on commit 51f5bbc

Please sign in to comment.