Commit 6c74e5f2 authored by Michal Čihař's avatar Michal Čihař

Extend fulltext migration tests

Now test also if searching works on updated indexes.
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 32370b62
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
Tests for search views. Tests for search views.
""" """
from __future__ import unicode_literals
import re import re
import shutil import shutil
import tempfile import tempfile
...@@ -32,7 +34,7 @@ from whoosh.fields import Schema, ID, TEXT ...@@ -32,7 +34,7 @@ from whoosh.fields import Schema, ID, TEXT
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from weblate.trans.tests.test_views import ViewTestCase from weblate.trans.tests.test_views import ViewTestCase
from weblate.trans.tests import OverrideSettings from weblate.trans.tests import OverrideSettings
from weblate.trans.search import update_index_unit from weblate.trans.search import update_index_unit, fulltext_search
import weblate.trans.search import weblate.trans.search
from weblate.trans.models import IndexUpdate from weblate.trans.models import IndexUpdate
...@@ -429,11 +431,28 @@ class SearchMigrationTest(TestCase): ...@@ -429,11 +431,28 @@ class SearchMigrationTest(TestCase):
if target is not None: if target is not None:
self.storage.create_index(target, 'target-cs') self.storage.create_index(target, 'target-cs')
self.assertIsNotNone( sindex = weblate.trans.search.get_source_index()
weblate.trans.search.get_source_index() self.assertIsNotNone(sindex)
) tindex = weblate.trans.search.get_target_index('cs')
self.assertIsNotNone( self.assertIsNotNone(tindex)
weblate.trans.search.get_target_index('cs') writer = sindex.writer()
writer.update_document(
pk=1,
source="text",
context="context",
location="location",
)
writer.commit()
writer = tindex.writer()
writer.update_document(
pk=1,
target="target",
comment="comment"
)
writer.commit()
self.assertEqual(
fulltext_search('text', 'cs', {'source': True}),
set([1])
) )
def test_nonexisting(self): def test_nonexisting(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment