tornado: Extract functions called from django into one module.

This makes clearer the separation of concerns.
This commit is contained in:
Alex Vandiver
2020-08-10 09:40:38 -07:00
committed by Tim Abbott
parent 33e19fa7d1
commit 39368cad3a
8 changed files with 106 additions and 103 deletions

View File

@@ -53,7 +53,7 @@ from zerver.models import (
get_realm,
get_stream,
)
from zerver.tornado import event_queue
from zerver.tornado import django_api as django_tornado_api
from zerver.tornado.handlers import AsyncDjangoHandler, allocate_handler_id
from zerver.worker import queue_processors
from zproject.backends import ExternalAuthDataDict, ExternalAuthResult
@@ -91,15 +91,15 @@ def simulated_queue_client(client: Callable[..., Any]) -> Iterator[None]:
@contextmanager
def tornado_redirected_to_list(lst: List[Mapping[str, Any]]) -> Iterator[None]:
real_event_queue_process_notification = event_queue.process_notification
event_queue.process_notification = lambda notice: lst.append(notice)
real_event_queue_process_notification = django_tornado_api.process_notification
django_tornado_api.process_notification = lambda notice: lst.append(notice)
# 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
yield
event_queue.process_notification = real_event_queue_process_notification
django_tornado_api.process_notification = real_event_queue_process_notification
class EventInfo:
def populate(self, call_args_list: List[Any]) -> None: