def test_find_all_by_fullname_two_users_default_order(self): search_term = 'lord' user_last = self.add_user(firstname='Lord', lastname='Sanderson') user_first = self.add_user(firstname='Great', lastname='Lord') self.add_user(firstname='Toto', lastname='Tata') result = user_dao.find_all_by_fullname(search_term) assert_that(result, has_length(2)) assert_that(result, contains( has_property('id', user_first.id), has_property('id', user_last.id), ))
def test_find_all_by_fullname_two_users_default_order(self): search_term = 'lord' user_last = self.add_user(firstname='Lord', lastname='Sanderson') user_first = self.add_user(firstname='Great', lastname='Lord') self.add_user(firstname='Toto', lastname='Tata') result = user_dao.find_all_by_fullname(search_term) assert_that(result, has_length(2)) assert_that( result, contains( has_property('id', user_first.id), has_property('id', user_last.id), ))
def test_find_all_by_fullname_partial(self): firstname = 'Lord' lastname = 'Sanderson' partial_fullname = 'd san' user = self.add_user(firstname=firstname, lastname=lastname) result = user_dao.find_all_by_fullname(partial_fullname) assert_that(result, has_length(1)) assert_that( result, contains( all_of(has_property('id', user.id), has_property('firstname', firstname), has_property('lastname', lastname))))
def test_find_all_by_fullname_lowercase(self): firstname = 'Lord' lastname = 'Sanderson' fullname = '%s %s' % (firstname, lastname) user = self.add_user(firstname=firstname, lastname=lastname) result = user_dao.find_all_by_fullname(fullname.lower()) assert_that(result, has_length(1)) assert_that( result, contains( all_of(has_property('id', user.id), has_property('firstname', firstname), has_property('lastname', lastname))))
def test_find_all_by_fullname_partial(self): firstname = 'Lord' lastname = 'Sanderson' partial_fullname = 'd san' user = self.add_user(firstname=firstname, lastname=lastname) result = user_dao.find_all_by_fullname(partial_fullname) assert_that(result, has_length(1)) assert_that(result, contains( all_of( has_property('id', user.id), has_property('firstname', firstname), has_property('lastname', lastname) )))
def test_find_all_by_fullname_lowercase(self): firstname = 'Lord' lastname = 'Sanderson' fullname = '%s %s' % (firstname, lastname) user = self.add_user(firstname=firstname, lastname=lastname) result = user_dao.find_all_by_fullname(fullname.lower()) assert_that(result, has_length(1)) assert_that(result, contains( all_of( has_property('id', user.id), has_property('firstname', firstname), has_property('lastname', lastname) )))
def test_find_all_by_fullname_no_users(self): result = user_dao.find_all_by_fullname('') assert_that(result, has_length(0))
def find_all_by_fullname(fullname): return user_dao.find_all_by_fullname(fullname)