def test_title(db): user = User(first_name='Guinea', last_name='Pig') db.session.add(user) db.session.flush() assert user.title == '' user.title = UserTitle.prof assert user.title == UserTitle.prof.title assert is_lazy_string(user.title) assert User.find_one(title=UserTitle.prof) == user
def test_get_full_name(last_name_first, last_name_upper, abbrev_first_name, expected): user = User(first_name='Guinea', last_name='Pig', title=UserTitle.none) name = user.get_full_name(last_name_first=last_name_first, last_name_upper=last_name_upper, abbrev_first_name=abbrev_first_name, show_title=False) assert name == expected # titled name with no title is the same titled_name = user.get_full_name(last_name_first=last_name_first, last_name_upper=last_name_upper, abbrev_first_name=abbrev_first_name, show_title=True) assert titled_name == expected # titled name with a non-empty title user.title = UserTitle.mr titled_name = user.get_full_name(last_name_first=last_name_first, last_name_upper=last_name_upper, abbrev_first_name=abbrev_first_name, show_title=True) assert titled_name == f'Mr {expected}'
def test_get_full_name(last_name_first, last_name_upper, abbrev_first_name, expected): user = User(first_name='Guinea', last_name='Pig', title=UserTitle.none) name = user.get_full_name(last_name_first=last_name_first, last_name_upper=last_name_upper, abbrev_first_name=abbrev_first_name, show_title=False) assert name == expected # titled name with no title is the same titled_name = user.get_full_name(last_name_first=last_name_first, last_name_upper=last_name_upper, abbrev_first_name=abbrev_first_name, show_title=True) assert titled_name == expected # titled name with a non-empty title user.title = UserTitle.mr titled_name = user.get_full_name(last_name_first=last_name_first, last_name_upper=last_name_upper, abbrev_first_name=abbrev_first_name, show_title=True) assert titled_name == 'Mr. {}'.format(expected)