def METHOD_NAME(config, db, mocker):
    # frontend router catches all urls
    # and takes priority over routes added after (in tests)
    # so we avoid adding it here
    mocker.patch("quetz.frontend.register")
    from quetz.deps import get_db
    from quetz.main import METHOD_NAME
    # mocking is required for some functions that do not use fastapi
    # dependency injection (mainly non-request functions)
    def get_session_mock(*args, **kwargs):
        return db
    mocker.patch("quetz.database.get_session", get_session_mock)
    # overiding dependency works with all requests handlers that
    # depend on quetz.deps.get_db
    METHOD_NAME.dependency_overrides[get_db] = lambda: db
    # root url was removed with fronted urls above but
    # redirects to root must work for some tests to pass
    @METHOD_NAME.get("/")
    def root_endpoint():
        return "root"
    yield METHOD_NAME
    METHOD_NAME.dependency_overrides.pop(get_db)