def test_update_user(db: Session) -> None: email = random_email() password = random_lower_string() user_in = UserCreate(email=email, password=password) user = services.user.create_user(user_in.to_dto()) new_password = random_lower_string() user_in_update = UserUpdate(password=new_password) services.user.update_user(user.provider_uuid, user.uuid, user_in_update.to_dto()) user_2 = services.user.get_user(user.uuid) assert user_2 assert user.email == user_2.email assert verify_password(new_password, user_2.password)
def authentication_token_from_email( *, client: TestClient, email: str, db: Session ) -> Dict[str, str]: """ Return a valid token for the user with given email. If the user doesn't exist it is created first. """ password = random_lower_string() user = services.user.get_user_by_email(email) if not user: user_in_create = UserCreate(email=email, password=password) user = services.user.create_user(user_in_create.to_dto()) else: user_in_update = UserUpdate(password=password) user = services.user.update_user( user.provider_uuid, user.uuid, user_in_update.to_dto() ) return user_authentication_headers(client=client, email=email, password=password)