def testDisplayName(self): user = User(first_name="Foo", last_name="Bar") self.assertEqual(get_display_name(user), "Foo Bar") user = User(first_name="Foo") self.assertEqual(get_display_name(user), "Foo") user = User(last_name="Bar") self.assertEqual(get_display_name(user), "Bar") user = User() self.assertEqual(get_display_name(user), "Anonymous") self.assertEqual(get_display_name(user, fallback="Baz"), "Baz")
def display_name(user, fallback=None): """Returns a display name for the user.""" return get_display_name(user, fallback=fallback)