Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

event_schema: Add checker for restart event.

shanukund68a2677d293
diff --git a/frontend_tests/node_tests/lib/events.js b/frontend_tests/node_tests/lib/events.js
index d20b6595f04..bf31860b788 100644
--- a/frontend_tests/node_tests/lib/events.js
+++ b/frontend_tests/node_tests/lib/events.js
@@ -479,6 +479,7 @@ exports.fixtures = {
restart: {
type: "restart",
+ server_generation: 2,
immediate: true,
},
diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py
index 5fad1c7f426..3e471aa3b42 100644
--- a/zerver/lib/event_schema.py
+++ b/zerver/lib/event_schema.py
@@ -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")),
diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.py
index dfc6d542f3a..20c7dafd3ef 100644
--- a/zerver/tests/test_event_system.py
+++ b/zerver/tests/test_event_system.py
@@ -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(