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