예제 #1
0
    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())
예제 #2
0
    ("reaction_type", str),
    ("user_id", int),
    ("user", reaction_legacy_user_type),
])
check_reaction_remove = make_checker(reaction_remove_event)

realm_deactivated_event = event_dict_type(required_keys=[
    ("type", Equals("realm")),
    ("op", Equals("deactivated")),
    ("realm_id", int),
])
check_realm_deactivated = make_checker(realm_deactivated_event)

bot_services_outgoing_type = DictType(required_keys=[
    # force vertical
    ("base_url", UrlType()),
    ("interface", int),
    ("token", str),
])

config_data_schema = StringDictType(str)

bot_services_embedded_type = DictType(required_keys=[
    # force vertical
    ("service_name", str),
    ("config_data", config_data_schema),
])

# Note that regular bots just get an empty list of services,
# so the sub_validator for ListType won't matter for them.
bot_services_type = ListType(