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_fail_mismatched_literal(self): template = PathTemplate('hello/world') self.assertRaises(ValidationException, template.match, 'hello/world2')
def test_fail_when_impossible_match(self): template = PathTemplate('hello/world') self.assertRaises(ValidationException, template.match, 'hello') template = PathTemplate('hello/world') self.assertRaises(ValidationException, template.match, 'hello/world/fail')
def test_len(self): self.assertEqual(len(PathTemplate('a/b/**/*/{a=hello/world}')), 6)
def test_render_with_unbound_in_middle(self): template = PathTemplate('bar/**/foo/*') url = template.render({'$0': '1/2', '$1': '3'}) self.assertEqual(url, 'bar/1/2/foo/3')