def test_data_type_schema(self) -> None: """ We really only test this to get test coverage. The code covered here is really only used in testing tools. """ test_schema = DictType([ ("type", Equals("realm")), ("maybe_n", OptionalType(int)), ("s", str), ("timestamp", NumberType()), ("flag", bool), ("tup", TupleType([int, str])), ("level", EnumType([1, 2, 3])), ("lst", ListType(int)), ("config", StringDictType(str)), ("value", UnionType([int, str])), ("url", UrlType()), ]) expected = """ test (dict): config (string_dict): value: str flag: bool level in [1, 2, 3] lst (list): type: int maybe_n: int s: str timestamp: number tup (tuple): 0: int 1: str type in ['realm'] url: str value (union): type: int type: str """ self.assertEqual(schema("test", test_schema).strip(), expected.strip())
StringDictType, TupleType, UnionType, UrlType, check_data, event_dict_type, make_checker, ) from zerver.lib.topic import ORIG_TOPIC, TOPIC_LINKS, TOPIC_NAME from zerver.models import Realm, Stream, Subscription, UserProfile # These fields are used for "stream" events, and are included in the # larger "subscription" events that also contain personal settings. basic_stream_fields = [ ("description", str), ("first_message_id", OptionalType(int)), ("history_public_to_subscribers", bool), ("invite_only", bool), ("is_announcement_only", bool), ("is_web_public", bool), ("message_retention_days", OptionalType(int)), ("name", str), ("rendered_description", str), ("stream_id", int), ("stream_post_policy", int), ("date_created", int), ] subscription_fields: Sequence[Tuple[str, object]] = [ *basic_stream_fields, ("audible_notifications", OptionalType(bool)),