mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
event_schema: Extract check_realm_filters.
We have some known issues with representing tuples in openapi, so we exempt realm_filters from the relevant check.
This commit is contained in:
@@ -70,6 +70,7 @@ EXEMPT_OPENAPI_NAMES = [
|
|||||||
"message_event",
|
"message_event",
|
||||||
# tuple handling
|
# tuple handling
|
||||||
"muted_topics_event",
|
"muted_topics_event",
|
||||||
|
"realm_filters_event",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -533,6 +533,25 @@ def check_realm_export(
|
|||||||
assert has_failed_timestamp == (export["failed_timestamp"] is not None)
|
assert has_failed_timestamp == (export["failed_timestamp"] is not None)
|
||||||
|
|
||||||
|
|
||||||
|
realm_filter_type = TupleType(
|
||||||
|
[
|
||||||
|
# we should make this an object
|
||||||
|
# see realm_filters_for_realm_remote_cache
|
||||||
|
str, # pattern
|
||||||
|
str, # format string
|
||||||
|
int, # id
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
realm_filters_event = event_dict_type(
|
||||||
|
[
|
||||||
|
# force vertical
|
||||||
|
("type", Equals("realm_filters")),
|
||||||
|
("realm_filters", ListType(realm_filter_type)),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
check_realm_filters = make_checker(realm_filters_event)
|
||||||
|
|
||||||
plan_type_extra_data_type = DictType(
|
plan_type_extra_data_type = DictType(
|
||||||
required_keys=[
|
required_keys=[
|
||||||
# force vertical
|
# force vertical
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ from zerver.lib.event_schema import (
|
|||||||
check_realm_bot_remove,
|
check_realm_bot_remove,
|
||||||
check_realm_bot_update,
|
check_realm_bot_update,
|
||||||
check_realm_export,
|
check_realm_export,
|
||||||
|
check_realm_filters,
|
||||||
check_realm_update,
|
check_realm_update,
|
||||||
check_realm_user_update,
|
check_realm_user_update,
|
||||||
check_stream_create,
|
check_stream_create,
|
||||||
@@ -148,7 +149,6 @@ from zerver.lib.validator import (
|
|||||||
check_list,
|
check_list,
|
||||||
check_none_or,
|
check_none_or,
|
||||||
check_string,
|
check_string,
|
||||||
check_tuple,
|
|
||||||
equals,
|
equals,
|
||||||
)
|
)
|
||||||
from zerver.models import (
|
from zerver.models import (
|
||||||
@@ -1385,21 +1385,13 @@ class NormalActionsTest(BaseAction):
|
|||||||
regex = "#(?P<id>[123])"
|
regex = "#(?P<id>[123])"
|
||||||
url = "https://realm.com/my_realm_filter/%(id)s"
|
url = "https://realm.com/my_realm_filter/%(id)s"
|
||||||
|
|
||||||
schema_checker = check_events_dict([
|
|
||||||
('type', equals('realm_filters')),
|
|
||||||
('realm_filters', check_list(check_tuple([
|
|
||||||
check_string,
|
|
||||||
check_string,
|
|
||||||
check_int,
|
|
||||||
]))),
|
|
||||||
])
|
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
lambda: do_add_realm_filter(self.user_profile.realm, regex, url))
|
lambda: do_add_realm_filter(self.user_profile.realm, regex, url))
|
||||||
schema_checker('events[0]', events[0])
|
check_realm_filters('events[0]', events[0])
|
||||||
|
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
lambda: do_remove_realm_filter(self.user_profile.realm, "#(?P<id>[123])"))
|
lambda: do_remove_realm_filter(self.user_profile.realm, "#(?P<id>[123])"))
|
||||||
schema_checker('events[0]', events[0])
|
check_realm_filters('events[0]', events[0])
|
||||||
|
|
||||||
def test_realm_domain_events(self) -> None:
|
def test_realm_domain_events(self) -> None:
|
||||||
schema_checker = check_events_dict([
|
schema_checker = check_events_dict([
|
||||||
|
|||||||
Reference in New Issue
Block a user