-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
50 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import unittest | ||
|
||
from django.conf import settings | ||
from django.db import connection | ||
from django.test import TestCase | ||
|
||
from wagtail.search.backends import get_search_backend | ||
from wagtail.tests.search import models | ||
|
||
|
||
class TestPostgresStemming(TestCase): | ||
def setUp(self): | ||
backend_name = "wagtail.contrib.postgres_search.backend" | ||
for conf in settings.WAGTAILSEARCH_BACKENDS.values(): | ||
if conf['BACKEND'] == backend_name: | ||
break | ||
else: | ||
raise unittest.SkipTest("Only for %s" % backend_name) | ||
|
||
self.backend = get_search_backend(backend_name) | ||
|
||
def test_ru_stemming(self): | ||
with connection.cursor() as cursor: | ||
cursor.execute( | ||
"SET default_text_search_config TO 'pg_catalog.russian'" | ||
) | ||
|
||
ru_book = models.Book.objects.create( | ||
title="Голубое сало", publication_date="1999-05-01", | ||
number_of_pages=352 | ||
) | ||
self.backend.add(ru_book) | ||
|
||
results = self.backend.search("Голубое", models.Book) | ||
self.assertEqual(list(results), [ru_book]) | ||
|
||
|
||
results = self.backend.search("Голубая", models.Book) | ||
self.assertEqual(list(results), [ru_book]) | ||
|
||
results = self.backend.search("Голубой", models.Book) | ||
self.assertEqual(list(results), [ru_book]) | ||
|
||
ru_book.delete() |
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