def test_match_atomic_resource_name(self): template = PathTemplate('buckets/*/*/objects/*') self.assertEqual({'$0': 'f', '$1': 'o', '$2': 'bar'}, template.match('buckets/f/o/objects/bar')) template = PathTemplate('/buckets/{hello}') self.assertEqual({'hello': 'world'}, template.match('buckets/world')) template = PathTemplate('/buckets/{hello=*}') self.assertEqual({'hello': 'world'}, template.match('buckets/world'))
def test_match_atomic_resource_name(self): template = PathTemplate('buckets/*/*/objects/*') self.assertEqual({ '$0': 'f', '$1': 'o', '$2': 'bar' }, template.match('buckets/f/o/objects/bar')) template = PathTemplate('/buckets/{hello}') self.assertEqual({'hello': 'world'}, template.match('buckets/world')) template = PathTemplate('/buckets/{hello=*}') self.assertEqual({'hello': 'world'}, template.match('buckets/world'))
def test_match_with_unbound_in_middle(self): template = PathTemplate('bar/**/foo/*') self.assertEqual({'$0': 'foo/foo', '$1': 'bar'}, template.match('bar/foo/foo/foo/bar'))
def test_match_template_with_unbounded_wildcard(self): template = PathTemplate('buckets/*/objects/**') self.assertEqual({'$0': 'foo', '$1': 'bar/baz'}, template.match('buckets/foo/objects/bar/baz'))
def test_match_escaped_chars(self): template = PathTemplate('buckets/*/objects') self.assertEqual({'$0': 'hello%2F%2Bworld'}, template.match('buckets/hello%2F%2Bworld/objects'))
def test_match_with_unbound_in_middle(self): template = PathTemplate('bar/**/foo/*') self.assertEqual({ '$0': 'foo/foo', '$1': 'bar' }, template.match('bar/foo/foo/foo/bar'))
def test_match_template_with_unbounded_wildcard(self): template = PathTemplate('buckets/*/objects/**') self.assertEqual({ '$0': 'foo', '$1': 'bar/baz' }, template.match('buckets/foo/objects/bar/baz'))