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']))),
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'])))
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']))),
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'])))
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(), [])))
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'])))
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')]), [])))
def test_multiple(self): """ Match a route with a multiple components. """ request = MockRequest() self.assertThat( route('foo', 'bar')(request, ['foo', 'bar']), Equals((OrderedDict(), [])))
def test_singleNoMatch(self): """ Do not match a route with a single component. """ request = MockRequest() self.assertThat( route('foo')(request, ['bar']), Equals((None, ['bar'])))
def test_single(self): """ Match a route with a single component. """ request = MockRequest() self.assertThat( route('foo')(request, ['foo']), Equals((OrderedDict(), [])))