from django.core.management import call_command
from django.test import TestCase
from model_mommy import mommy


class IntegrationTestCase(TestCase):

    def rebuild_index(self):
        call_command('rebuild_index', verbosity=0, interactive=False)


class IntegrationTestUsers(IntegrationTestCase):

    def test_search_users_in_elasticsearch(self):
        user = mommy.make(User, first_name='John', last_name='Smith')
user = mommy.make(User, first_name='Andy', last_name='Smith')
user = mommy.make(User, first_name='Jane', last_name='Smith')
self.rebuild_index()
Модульное тестирование эластичного поиска внутри приложения Django