Debian Codegraph @

tests/schema_registry/test_wildcard_matcher.py

raw symbols SCIP
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # Copyright 2024 Confluent Inc.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19
20 def test_wildcard_matcher():
21 from confluent_kafka.schema_registry.wildcard_matcher import wildcard_match
22
23 assert not wildcard_match("", "Foo")
24 assert not wildcard_match("Foo", "")
25 assert wildcard_match("", "")
26 assert wildcard_match("Foo", "Foo")
27 assert wildcard_match("", "*")
28 assert not wildcard_match("", "?")
29 assert wildcard_match("Foo", "Fo*")
30 assert wildcard_match("Foo", "Fo?")
31 assert wildcard_match("Foo Bar and Catflag", "Fo*")
32 assert wildcard_match("New Bookmarks", "N?w ?o?k??r?s")
33 assert not wildcard_match("Foo", "Bar")
34 assert wildcard_match("Foo Bar Foo", "F*o Bar*")
35 assert wildcard_match("Adobe Acrobat Installer", "Ad*er")
36 assert wildcard_match("Foo", "*Foo")
37 assert wildcard_match("BarFoo", "*Foo")
38 assert wildcard_match("Foo", "Foo*")
39 assert wildcard_match("FooBar", "Foo*")
40 assert not wildcard_match("FOO", "*Foo")
41 assert not wildcard_match("BARFOO", "*Foo")
42 assert not wildcard_match("FOO", "Foo*")
43 assert not wildcard_match("FOOBAR", "Foo*")
44 assert wildcard_match("eve", "eve*")
45 assert wildcard_match("alice.bob.eve", "a*.bob.eve")
46 assert not wildcard_match("alice.bob.eve", "a*")
47 assert wildcard_match("alice.bob.eve", "a**")
48 assert not wildcard_match("alice.bob.eve", "alice.bob*")
49 assert wildcard_match("alice.bob.eve", "alice.bob**")