def test_app_client(mock_user_db, mock_authentication, event_handler) -> TestClient: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db ) user_router = get_user_router( mock_user_db, User, UserCreate, UserUpdate, UserDB, authenticator, SECRET, LIFETIME, ) user_router.add_event_handler(Event.ON_AFTER_REGISTER, event_handler) user_router.add_event_handler(Event.ON_AFTER_FORGOT_PASSWORD, event_handler) user_router.add_event_handler(Event.ON_AFTER_UPDATE, event_handler) app = FastAPI() app.include_router(user_router) return TestClient(app)
async def test_app_client(mock_user_db, mock_authentication, get_test_client) -> httpx.AsyncClient: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) mock_auth_router = get_auth_router(mock_authentication, mock_user_db, authenticator) mock_bis_auth_router = get_auth_router(mock_authentication_bis, mock_user_db, authenticator) app = FastAPI() app.include_router(mock_auth_router, prefix="/mock") app.include_router(mock_bis_auth_router, prefix="/mock-bis") return await get_test_client(app)
async def test_app_client( mock_user_db, mock_authentication, get_test_client) -> AsyncGenerator[httpx.AsyncClient, None]: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) mock_auth_router = get_auth_router(mock_authentication, mock_user_db, authenticator) mock_bis_auth_router = get_auth_router(mock_authentication_bis, mock_user_db, authenticator) app = FastAPI() app.include_router(mock_auth_router, prefix="/mock") app.include_router(mock_bis_auth_router, prefix="/mock-bis") async for client in get_test_client(app): yield client
def _app_factory(requires_verification: bool) -> FastAPI: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) user_router = get_users_router( mock_user_db, User, UserUpdate, UserDB, authenticator, after_update, requires_verification=requires_verification, ) app = FastAPI() app.include_router(user_router) return app
async def test_app_client(mock_user_db, mock_authentication, after_update, get_test_client) -> httpx.AsyncClient: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) user_router = get_users_router( mock_user_db, User, UserUpdate, UserDB, authenticator, after_update, ) app = FastAPI() app.include_router(user_router) return await get_test_client(app)
async def _get_test_app_client(redirect_url: str = None) -> httpx.AsyncClient: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db_oauth ) oauth_router = get_oauth_router( oauth_client, mock_user_db_oauth, UserDB, authenticator, SECRET, redirect_url, after_register, ) app = FastAPI() app.include_router(oauth_router) return await get_test_client(app)
def _get_test_app_client(redirect_url: str = None) -> TestClient: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db_oauth) oauth_router = get_oauth_router( oauth_client, mock_user_db_oauth, UserDB, authenticator, SECRET, redirect_url, ) oauth_router.add_event_handler(Event.ON_AFTER_REGISTER, event_handler) app = FastAPI() app.include_router(oauth_router) return TestClient(app)
async def test_app_client( mock_user_db, mock_authentication, after_update, get_test_client) -> AsyncGenerator[httpx.AsyncClient, None]: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) user_router = get_users_router( mock_user_db, User, UserUpdate, UserDB, authenticator, after_update, ) app = FastAPI() app.include_router(user_router) async for client in get_test_client(app): yield client
async def _get_test_app_client( redirect_url: str = None, ) -> AsyncGenerator[httpx.AsyncClient, None]: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db_oauth) oauth_router = get_oauth_router( oauth_client, mock_user_db_oauth, UserDB, authenticator, SECRET, redirect_url, after_register, ) app = FastAPI() app.include_router(oauth_router) async for client in get_test_client(app): yield client
def _app_factory(requires_verification: bool) -> FastAPI: mock_authentication_bis = MockAuthentication(name="mock-bis") authenticator = Authenticator( [mock_authentication, mock_authentication_bis], mock_user_db) mock_auth_router = get_auth_router( mock_authentication, mock_user_db, authenticator, requires_verification=requires_verification, ) mock_bis_auth_router = get_auth_router( mock_authentication_bis, mock_user_db, authenticator, requires_verification=requires_verification, ) app = FastAPI() app.include_router(mock_auth_router, prefix="/mock") app.include_router(mock_bis_auth_router, prefix="/mock-bis") return app