def create_user(name, email, password: str): if User.autenticate(email) is not None: return errors.bad_request({"email": "Email is already exists."}) try: new_user = User.create(name, email, password) new_user.save() except SaveError as err: return errors.internal_error(err.messages) return new_user, 201
def register(name: str, email: str, password: str): user = User.autenticate(email) if user is not None: return errors.bad_request( "User with this email is already in the system. Are you trying to logged in?" ) user = User.create(name, email, password) user.save() return jwt_utils.response_with_tokens(user), 201
def test_user_create(app): user = User.create("Tester", "*****@*****.**", _SOME_USER_PASSWORD) assert user.verify_passw(_SOME_USER_PASSWORD, user.password) user.save() assert user.id == _DEFAULT_USERS_COUNT + 1