def test_userprofiles(app): """Test UserProfile model.""" profile = UserProfile() # Check the username validator works on the model profile.username = test_usernames['valid'] with pytest.raises(ValueError): profile.username = test_usernames['invalid_characters'] with pytest.raises(ValueError): profile.username = test_usernames['invalid_begins_with_number'] # Test non-validated attributes profile.first_name = 'Test' profile.last_name = 'User' assert profile.first_name == 'Test' assert profile.last_name == 'User'
def test_userprofiles(app): """Test UserProfile model.""" profile = UserProfile() # Check the username validator works on the model profile.username = test_usernames['valid'] with pytest.raises(ValueError): profile.username = test_usernames['invalid_characters'] with pytest.raises(ValueError): profile.username = test_usernames['invalid_begins_with_number'] # Test non-validated attributes profile.first_name = 'Test' profile.last_name = 'User' assert profile.first_name == 'Test' assert profile.last_name == 'User'
def create_userprofile_for(email, username, full_name): """Create a fake user profile.""" user = User.query.filter_by(email=email).one_or_none() if user: profile = UserProfile(user_id=int(user.get_id())) profile.username = username profile.full_name = full_name db.session.add(profile) db.session.commit()
def create_userprofile_for(email, username, full_name): """Create a fake user profile.""" user = User.query.filter_by(email=email).one_or_none() if user: profile = UserProfile(user_id=int(user.get_id())) profile.username = username profile.full_name = full_name db.session.add(profile) db.session.commit() click.secho("User profile created for {}".format(email), fg="green") else: click.secho("ERROR: user {} does not exist".format(email), fg="red")