Ejemplo n.º 1
0
 def test_multipleNoMatch(self):
     """
     Do not match a route with a multiple components.
     """
     request = MockRequest()
     self.assertThat(
         route(Text('name'), Integer('name2'))(request, ['foo', 'bar']),
         Equals((None, ['foo', 'bar'])))
     self.assertThat(
         route(Integer('name'), Text('name2'))(request, ['foo', 'bar']),
         Equals((None, ['foo', 'bar']))),
Ejemplo n.º 2
0
 def test_tooMany(self):
     """
     Do not match a route that has too many components or segments.
     """
     request = MockRequest()
     self.assertThat(
         route(Text('name'), Integer('name2'))(request, ['foo']),
         Equals((None, ['foo'])))
     self.assertThat(
         route(Text('name'))(request, ['foo', 'bar']),
         Equals((None, ['foo', 'bar'])))
Ejemplo n.º 3
0
 def test_multipleNoMatch(self):
     """
     Do not match a route with a multiple components.
     """
     request = MockRequest()
     self.assertThat(
         route('bar')(request, ['foo', 'bar']),
         Equals((None, ['foo', 'bar'])))
     self.assertThat(
         route('foo', 'quux')(request, ['foo', 'bar']),
         Equals((None, ['foo', 'bar']))),
Ejemplo n.º 4
0
 def test_nullRoute(self):
     """
     The null route matches only zero segments.
     """
     request = MockRequest()
     self.assertThat(
         route()(request, []),
         Equals((OrderedDict(), [])))
     self.assertThat(
         route()(request, ['foo']),
         Equals((None, ['foo'])))
Ejemplo n.º 5
0
 def test_emptyRoute(self):
     """
     Both `route('')` and `route('/')` match the empty route.
     """
     request = MockRequest()
     self.assertThat(
         route('/')(request, ['']),
         Equals((OrderedDict(), [])))
     self.assertThat(
         route('')(request, ['']),
         Equals((OrderedDict(), [])))
Ejemplo n.º 6
0
 def test_tooMany(self):
     """
     Do not match a route that has too many components or segments.
     """
     request = MockRequest()
     self.assertThat(
         route('foo', 'bar')(request, ['foo']),
         Equals((None, ['foo'])))
     request = MockRequest()
     self.assertThat(
         route('foo')(request, ['foo', 'bar']),
         Equals((None, ['foo', 'bar'])))
Ejemplo n.º 7
0
 def test_multiple(self):
     """
     Match a route with a multiple components.
     """
     request = MockRequest()
     segments = ['foo', 'bar', 'quux']
     self.assertThat(
         route(
             Text('name'), 'bar', 'quux')(request, segments),
         Equals(
             (OrderedDict([('name', 'foo')]), [])))
     self.assertThat(
         route(Text('name'), 'bar', Text('name2'))(request, segments),
         Equals(
             (OrderedDict([('name', 'foo'),
                           ('name2', 'quux')]), [])))
Ejemplo n.º 8
0
 def test_multiple(self):
     """
     Match a route with a multiple components.
     """
     request = MockRequest()
     self.assertThat(
         route('foo', 'bar')(request, ['foo', 'bar']),
         Equals((OrderedDict(), [])))
Ejemplo n.º 9
0
 def test_singleNoMatch(self):
     """
     Do not match a route with a single component.
     """
     request = MockRequest()
     self.assertThat(
         route('foo')(request, ['bar']),
         Equals((None, ['bar'])))
Ejemplo n.º 10
0
 def test_single(self):
     """
     Match a route with a single component.
     """
     request = MockRequest()
     self.assertThat(
         route('foo')(request, ['foo']),
         Equals((OrderedDict(), [])))