event_schema: Add checker for restart event.

Part of #17568.
This commit is contained in:
shanukun
2021-03-14 03:02:51 +05:30
committed by Tim Abbott
parent cfe0fa3788
commit d68a2677d2
3 changed files with 8 additions and 3 deletions

View File

@@ -479,6 +479,7 @@ exports.fixtures = {
restart: {
type: "restart",
server_generation: 2,
immediate: true,
},

View File

@@ -1085,6 +1085,11 @@ def check_realm_user_update(
)
restart_event = event_dict_type(
required_keys=[("type", Equals("restart")), ("server_generation", int), ("immediate", bool)]
)
check_restart_event = make_checker(restart_event)
stream_create_event = event_dict_type(
required_keys=[
("type", Equals("stream")),

View File

@@ -7,6 +7,7 @@ from django.conf import settings
from django.http import HttpRequest, HttpResponse
from zerver.lib.actions import check_send_message, do_change_user_role, do_set_realm_property
from zerver.lib.event_schema import check_restart_event
from zerver.lib.events import fetch_initial_state_data, get_raw_user_data
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import HostRequestMock, queries_captured, stub_event_queue_user_events
@@ -816,9 +817,7 @@ class RestartEventsTest(ZulipTestCase):
self.assertEqual(len(virtual_events), 1)
restart_event = virtual_events["restart"]
# TODO: add a schema checker for this to event_schema.py
# and exercise it here (as well as the more concrete
# check)
check_restart_event("restart_event", restart_event)
self.assertEqual(
restart_event,
dict(