api: Handle restart events in apply_events.

Event of type restart could not be handled properly, because of
its special behavior. For handling this event in most natural way
we recursively call `do_events_register` when restart event is
recieved, based on custom error created for this event.

Testing: Second call to get_user_events due to recursive calling
of do_event_register, is expected to not contain the restart event.
So new test added in test_event_system.py are based on above behavior
of get_user_events.

Fixes: #15541.
This commit is contained in:
m-e-l-u-h-a-n
2021-04-29 16:24:30 +05:30
committed by Tim Abbott
parent 2a4452e722
commit d2c18e28a4
3 changed files with 134 additions and 12 deletions

View File

@@ -51,6 +51,7 @@ from zerver.models import (
Subscription,
UserMessage,
UserProfile,
get_client,
get_realm,
get_stream,
)
@@ -327,10 +328,13 @@ class HostRequestMock:
post_data: Dict[str, Any] = {},
user_profile: Optional[UserProfile] = None,
host: str = settings.EXTERNAL_HOST,
client_name: Optional[str] = None,
) -> None:
self.host = host
self.GET: Dict[str, Any] = {}
self.method = ""
if client_name is not None:
self.client = get_client(client_name)
# Convert any integer parameters passed into strings, even
# though of course the HTTP API would do so. Ideally, we'd