Example #1
0
def test_get_full_name_empty_names(first_name, last_name):
    user = User(first_name=first_name, last_name=last_name, title=UserTitle.none)
    for last_name_first, last_name_upper, abbrev_first_name in itertools.product((True, False), repeat=3):
        # Just make sure it doesn't fail. We don't really care about the output.
        # It's only allowed for pending users so in most cases it only shows up
        # in the ``repr`` of such a user.
        user.get_full_name(last_name_first=last_name_first, last_name_upper=last_name_upper,
                           abbrev_first_name=abbrev_first_name)
Example #2
0
def test_get_full_name_empty_names(first_name, last_name):
    user = User(first_name=first_name, last_name=last_name, title=UserTitle.none)
    for last_name_first, last_name_upper, abbrev_first_name in itertools.product((True, False), repeat=3):
        # Just make sure it doesn't fail. We don't really care about the output.
        # It's only allowed for pending users so in most cases it only shows up
        # in the ``repr`` of such a user.
        user.get_full_name(last_name_first=last_name_first, last_name_upper=last_name_upper,
                           abbrev_first_name=abbrev_first_name)
Example #3
0
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}'
Example #4
0
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)