Forked from justquick/django_haystack_testing
Last active
September 14, 2018 13:07
-
-
Save cstrap/5b708c631a51e2d64c2f to your computer and use it in GitHub Desktop.
Django haystack testing index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haystack | |
from django.core.management import call_command | |
from django.test.utils import override_settings | |
TEST_INDEX = { | |
'default': { | |
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', | |
'URL': 'http://127.0.0.1:9200/', | |
'TIMEOUT': 60 * 10, | |
'INDEX_NAME': 'test_index', | |
}, | |
} | |
@override_settings(HAYSTACK_CONNECTIONS=TEST_INDEX) | |
class BaseTestCase(TestCase): | |
def setUp(self): | |
haystack.connections.reload('default') | |
super(BaseTestCase, self).setUp() | |
def tearDown(self): | |
call_command('clear_index', interactive=False, verbosity=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment