'Test route construction'

def test_route_construction(self):

    from calibre.srv.routes import Route, endpoint, RouteError
    def makeroute(route, func=(lambda c, d: None), **kwargs):
        return Route(endpoint(route, **kwargs)(func))
    r = makeroute(u'/')
    self.ae(r.matchers, [])
    self.assertFalse(r.required_names)
    r = makeroute(u'/slash/')
    self.ae(r.endpoint.route, u'/slash')
    def emr(route):
        self.assertRaises(RouteError, makeroute, route)
    emr(u'no_start')
    emr(u'/{xxx')
    emr(u'/{+all}/{other}')
    emr(u'/{t=}}')
    emr(u'/{+all=1}')
    emr(u'/{d=1}/no')
    emr(u'/x/{a=1}')
    self.assertRaises(RouteError, makeroute, u'/a/b', (lambda c, d, b, a: None))
