def get_register_router(self) -> APIRouter: """Return a router with a register route.""" return get_register_router( self.get_user_manager, self._user_model, self._user_create_model, )
async def test_register_namespace(get_user_manager): app = FastAPI() app.include_router( get_register_router( get_user_manager, User, UserCreate, ) ) assert app.url_path_for("register:register") == "/register"
async def test_app_client(mock_user_db, mock_authentication, after_register, get_test_client) -> httpx.AsyncClient: register_router = get_register_router( mock_user_db, User, UserCreate, UserDB, after_register, ) app = FastAPI() app.include_router(register_router) return await get_test_client(app)
async def test_app_client( get_user_manager, get_test_client ) -> AsyncGenerator[httpx.AsyncClient, None]: register_router = get_register_router( get_user_manager, User, UserCreate, ) app = FastAPI() app.include_router(register_router) async for client in get_test_client(app): yield client
def get_register_router( self, after_register: Optional[Callable[[models.UD, Request], None]] = None, ) -> APIRouter: """ Return a router with a register route. :param after_register: Optional function called after a successful registration. """ return get_register_router( self.create_user, self._user_model, self._user_create_model, after_register, )
async def test_app_client( mock_user_db, after_register, get_test_client) -> AsyncGenerator[httpx.AsyncClient, None]: create_user = get_create_user(mock_user_db, UserDB) register_router = get_register_router( create_user, User, UserCreate, after_register, ) app = FastAPI() app.include_router(register_router) async for client in get_test_client(app): yield client
async def test_app_client( mock_user_db, mock_authentication, after_register, activation_callback, get_test_client, ) -> AsyncGenerator[httpx.AsyncClient, None]: register_router = get_register_router( mock_user_db, User, UserCreate, UserDB, after_register, activation_callback, activation_token_secret, activation_token_lifetime_seconds, ) app = FastAPI() app.include_router(register_router) async for client in get_test_client(app): yield client
def get_register_router( self, after_register: Optional[Callable[[models.UD, Request], None]] = None, activation_callback: Optional[Callable[[models.UD, str, Request], None]] = None, activation_token_secret: str = None, activation_token_lifetime_seconds: int = 3600, ) -> APIRouter: """ Return a router with a register route. :param after_register: Optional function called after a successful registration. """ return get_register_router( self.db, self._user_model, self._user_create_model, self._user_db_model, after_register, activation_callback, activation_token_secret, activation_token_lifetime_seconds, )