From 6f5f38076a72b501296630ba63d973d8f2fbe77f Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Wed, 16 Aug 2017 18:02:57 +0200 Subject: [PATCH] Adds missing changes from 2379da96e4ea250cb09ac20dab2d60776ea75d32. --- wagtail/wagtailsearch/tests/test_backends.py | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wagtail/wagtailsearch/tests/test_backends.py b/wagtail/wagtailsearch/tests/test_backends.py index 12d882b4d9..cecd4ef165 100644 --- a/wagtail/wagtailsearch/tests/test_backends.py +++ b/wagtail/wagtailsearch/tests/test_backends.py @@ -178,6 +178,27 @@ class BackendTests(WagtailTestUtils): results = self.backend.search("A subobject", models.SearchTest) self.assertEqual(set(results), {self.testa}) + def test_boost(self): + results = self.backend.search('Hello', models.SearchTest) + # The `content` field has more boost, so the object containing “Hello” + # should be before the ones having it in the title, + # despite the insertion order. + self.assertListEqual( + list(results), [self.testc.searchtest_ptr, self.testa, self.testb]) + + def test_order_by_relevance(self): + sorted_results = self.backend.search('Hello', models.SearchTest, + order_by_relevance=True) + self.assertListEqual( + list(sorted_results), + [self.testc.searchtest_ptr, self.testa, self.testb]) + + unsorted_results = self.backend.search('Hello', models.SearchTest, + order_by_relevance=False) + self.assertListEqual( + list(unsorted_results), + [self.testa, self.testb, self.testc.searchtest_ptr]) + def test_delete(self): # Delete one of the objects self.backend.delete(self.testa)