mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
test_classes: Use mock.patch in tornado_redirected_to_list.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
1ae56e466b
commit
1a985911ef
@@ -98,7 +98,6 @@ from zerver.models import (
|
||||
get_user_by_delivery_email,
|
||||
)
|
||||
from zerver.openapi.openapi import validate_against_openapi_schema, validate_request
|
||||
from zerver.tornado import django_api as django_tornado_api
|
||||
from zerver.tornado.event_queue import clear_client_event_queues_for_testing
|
||||
|
||||
if settings.ZILENCER_ENABLED:
|
||||
@@ -1314,15 +1313,15 @@ Output:
|
||||
self, lst: List[Mapping[str, Any]], expected_num_events: int
|
||||
) -> Iterator[None]:
|
||||
lst.clear()
|
||||
real_event_queue_process_notification = django_tornado_api.process_notification
|
||||
|
||||
# process_notification takes a single parameter called 'notice'.
|
||||
# lst.append takes a single argument called 'object'.
|
||||
# Some code might call process_notification using keyword arguments,
|
||||
# so mypy doesn't allow assigning lst.append to process_notification
|
||||
# So explicitly change parameter name to 'notice' to work around this problem
|
||||
django_tornado_api.process_notification = lambda notice: lst.append(notice)
|
||||
|
||||
with mock.patch(
|
||||
"zerver.tornado.django_api.process_notification", lambda notice: lst.append(notice)
|
||||
):
|
||||
# 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
|
||||
@@ -1331,8 +1330,6 @@ Output:
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
yield
|
||||
|
||||
django_tornado_api.process_notification = real_event_queue_process_notification
|
||||
|
||||
self.assert_length(lst, expected_num_events)
|
||||
|
||||
def create_user_notifications_data_object(
|
||||
|
||||
Reference in New Issue
Block a user