def test_filter_prefix(self): # Test 1-char prefix filter test_query = TestPerson.all() test_criteria = {'name': 'b'} prefix.filter_prefix(test_query, **test_criteria) assert test_query._get_query() == {'name_n1_ =': u'B'} # Test 2-char prefix filter test_query = TestPerson.all() test_criteria = {'name': 'bryan'} prefix.filter_prefix(test_query, **test_criteria) assert test_query._get_query() == {'name_n2_ =': u'BR'}
def search(self, criteria, new_search): if new_search: return indexing.search(Person, criteria, MAX_RESULTS) else: query = Person.all().order("entry_date") query = prefix.filter_prefix(query, **criteria) return list(prefix.get_prefix_matches(query, MAX_RESULTS, **criteria))