diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py index 1c567de071..3b294854b4 100644 --- a/zerver/lib/event_schema.py +++ b/zerver/lib/event_schema.py @@ -506,6 +506,14 @@ check_stream_create = check_events_dict( ] ) +check_stream_delete = check_events_dict( + required_keys=[ + ("type", equals("stream")), + ("op", equals("delete")), + ("streams", check_list(check_dict_only(basic_stream_fields))), + ] +) + _check_stream_update = check_events_dict( required_keys=[ ("type", equals("stream")), diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 5a783854a2..c36412d290 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -91,7 +91,6 @@ from zerver.lib.actions import ( ) from zerver.lib.event_schema import ( avatar_fields, - basic_stream_fields, check_alert_words, check_custom_profile_fields, check_default_stream_groups, @@ -107,6 +106,7 @@ from zerver.lib.event_schema import ( check_realm_update, check_realm_user_update, check_stream_create, + check_stream_delete, check_stream_update, check_submessage, check_subscription_add, @@ -1649,12 +1649,7 @@ class NormalActionsTest(BaseAction): action = lambda: do_deactivate_stream(stream) events = self.verify_action(action) - schema_checker = check_events_dict([ - ('type', equals('stream')), - ('op', equals('delete')), - ('streams', check_list(check_dict_only(basic_stream_fields))), - ]) - schema_checker('events[0]', events[0]) + check_stream_delete('events[0]', events[0]) def test_subscribe_other_user_never_subscribed(self) -> None: action = lambda: self.subscribe(self.example_user("othello"), "test_stream")