def post(self): """Register a user""" args = user_request_parser.parse_args() invalid_input = validate_inputs(args) if invalid_input: return make_response( jsonify({ "message": "{} must be a string of maximum {} characters".format( invalid_input[2], invalid_input[1]) }), 400) first_name = args.get("first_name", None) last_name = args.get("last_name", None) username = args.get("username", None) user = User.query.filter_by(username=username).first() if not user: user = User(first_name, last_name, username) db.session.add(user) db.session.commit() return make_response(jsonify({"message": "User added"}), 201) return make_response(jsonify({"message": "User already exists"}), 409)
def gen_user(): username = fake.user_name() password = '******' first_name = fake.first_name() last_name = fake.last_name() email = fake.ascii_email() phone = fake.phone_number() user = User(username=username, password=password, first_name=first_name, last_name=last_name, email=email) user.save() company = ran_company() Staff.objects.create( companies=user, company_staff=company, ) # company.staffs.add(user) print(user)
def get_user(name=None): usr = User(name) usr.lang_metric return jsonify(usr.to_dict())
def get_me(): usr = User() # usr.lang_metric() usr.lang_metric return jsonify(usr.to_dict())
def test_login_user(self): usr = User() self.assertTrue(usr.is_login)
def test_create_user(self): usr = User("Ostoyae") self.assertIsInstance(usr, User)
def setUpClass(cls) -> None: cls.usr = User("Ostoyae")