def test_subrouter_groupdict(router, mock_req, mounts, req_path, match_dict): subrouter = Router() endpoint = mock.Mock() subrouter.add_route(GET, mounts[1], endpoint) router.add_router(mounts[0], subrouter) m = [x for x in router.match_routes(mock_req)] if m: assert m[0] is endpoint
def router(self): """ Property returning the router at the top of the middleware chain's stack (the last item in the list). If the list is empty OR the item is not an instance of growler.Router, one is created and added to the middleware chain, matching all requests. """ if not self.has_root_router: self.middleware.add(HTTPMethod.ALL, MiddlewareChain.ROOT_PATTERN, Router()) return self.middleware.last().func
def test_property_subrouter(router): subrouter = Router() router.add(0, '/', subrouter) subrouters = list(router.subrouters) assert len(subrouters) == 1 assert subrouters[0].func is subrouter