Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
event_schema: Extract check_custom_profile_fields.
Steve Howell0a9a9d8258fc
diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.pyindex 99e2a9d923a..e67015783c2 100644--- a/zerver/lib/event_schema.py+++ b/zerver/lib/event_schema.py@@ -109,6 +109,25 @@ check_optional_value = check_union(])+_check_custom_profile_field = check_dict_only(+ required_keys=[+ ("id", check_int),+ ("type", check_int),+ ("name", check_string),+ ("hint", check_string),+ ("field_data", check_string),+ ("order", check_int),+ ]+)++check_custom_profile_fields = check_events_dict(+ required_keys=[+ ("type", equals("custom_profile_fields")),+ ("op", equals("add")),+ ("fields", check_list(_check_custom_profile_field)),+ ]+)+check_invites_changed = check_events_dict(required_keys=[# the most boring event...no metadatadiff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.pyindex d7c27e8dbf5..ca5778f6cc7 100644--- a/zerver/tests/test_events.py+++ b/zerver/tests/test_events.py@@ -91,6 +91,7 @@ from zerver.lib.actions import ()from zerver.lib.event_schema import (basic_stream_fields,+ check_custom_profile_fields,check_events_dict,check_invites_changed,check_message,@@ -618,25 +619,12 @@ class NormalActionsTest(BaseAction):check_typing_start('events[0]', events[0])def test_custom_profile_fields_events(self) -> None:- schema_checker = check_events_dict([- ('type', equals('custom_profile_fields')),- ('op', equals('add')),- ('fields', check_list(check_dict_only([- ('id', check_int),- ('type', check_int),- ('name', check_string),- ('hint', check_string),- ('field_data', check_string),- ('order', check_int),- ]))),- ])-events = self.verify_action(lambda: notify_realm_custom_profile_fields(self.user_profile.realm, 'add'),state_change_expected=False,)- schema_checker('events[0]', events[0])+ check_custom_profile_fields('events[0]', events[0])realm = self.user_profile.realmfield = realm.customprofilefield_set.get(realm=realm, name='Biography')@@ -649,7 +637,7 @@ class NormalActionsTest(BaseAction):self.user_profile.realm, 'add'),state_change_expected=False,)- schema_checker('events[0]', events[0])+ check_custom_profile_fields('events[0]', events[0])def test_custom_profile_field_data_events(self) -> None:schema_checker_basic = check_events_dict([