コード例 #1
0
 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'))
コード例 #2
0
 def test_match_escaped_chars(self):
     template = PathTemplate('buckets/*/objects')
     self.assertEqual({'$0': 'hello%2F%2Bworld'},
                      template.match('buckets/hello%2F%2Bworld/objects'))
コード例 #3
0
 def test_fail_mismatched_literal(self):
     template = PathTemplate('hello/world')
     self.assertRaises(ValidationException, template.match, 'hello/world2')
コード例 #4
0
 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')
コード例 #5
0
 def test_len(self):
     self.assertEqual(len(PathTemplate('a/b/**/*/{a=hello/world}')), 6)
コード例 #6
0
 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')