Commit 8c2094ee91a3903ce160e8d44448e74da739f924

Authored by Sergio Oliveira
1 parent 81d42b1b

Using whoosh as search engine for tests

colab/accounts/views.py
... ... @@ -3,6 +3,8 @@
3 3  
4 4 from collections import OrderedDict
5 5  
  6 +from haystack.exceptions import SearchBackendError
  7 +
6 8 from django.conf import settings
7 9 from django.contrib import messages
8 10 from django.db import transaction
... ... @@ -106,7 +108,10 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView):
106 108 for filter_or in fields_or_lookup:
107 109 sqs = sqs.filter_or(**filter_or).exclude(type='thread')
108 110  
109   - context['results'] = sqs.order_by('-modified', '-created')[:10]
  111 + try:
  112 + context['results'] = sqs.order_by('-modified', '-created')[:10]
  113 + except SearchBackendError:
  114 + context['results'] = sqs.order_by('-modified')[:10]
110 115  
111 116 email_pks = [addr.pk for addr in user.emails.iterator()]
112 117 query = Message.objects.filter(from_address__in=email_pks)
... ...
colab/tests/__init__.py 0 → 100644
colab/tests/settings.py 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +from ..settings import *
  2 +
  3 +
  4 +import os
  5 +HAYSTACK_CONNECTIONS = {
  6 + 'default': {
  7 + 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  8 + 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
  9 + },
  10 +}
... ...
requirements_test.txt 0 → 100644
... ... @@ -0,0 +1 @@
  1 +Whoosh==2.5.7
... ...