From 389835438ce18fdd38e2af3a98f1065755b7c468 Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Fri, 11 May 2018 18:03:23 +0200 Subject: [PATCH] Test annotate_score on PostgreSQL search backend. --- wagtail/search/tests/elasticsearch_common_tests.py | 13 ------------- wagtail/search/tests/test_backends.py | 13 +++++++++++++ wagtail/search/tests/test_db_backend.py | 10 ++++++++++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/wagtail/search/tests/elasticsearch_common_tests.py b/wagtail/search/tests/elasticsearch_common_tests.py index 286fb3ad53..2ec46a27b0 100644 --- a/wagtail/search/tests/elasticsearch_common_tests.py +++ b/wagtail/search/tests/elasticsearch_common_tests.py @@ -114,19 +114,6 @@ class ElasticsearchCommonSearchBackendTests(BackendTests): results = self.backend.search(MATCH_ALL, models.Book) self.assertSetEqual(set(results), set()) - def test_annotate_score(self): - results = self.backend.search("JavaScript", models.Book).annotate_score('_score') - - for result in results: - self.assertIsInstance(result._score, float) - - def test_annotate_score_with_slice(self): - # #3431 - Annotate score wasn't being passed to new queryset when slicing - results = self.backend.search("JavaScript", models.Book).annotate_score('_score')[:10] - - for result in results: - self.assertIsInstance(result._score, float) - def test_more_than_ten_results(self): # #3431 reported that Elasticsearch only sends back 10 results if the results set is not sliced results = self.backend.search(MATCH_ALL, models.Book) diff --git a/wagtail/search/tests/test_backends.py b/wagtail/search/tests/test_backends.py index 228985aa7d..3b20e60e89 100644 --- a/wagtail/search/tests/test_backends.py +++ b/wagtail/search/tests/test_backends.py @@ -78,6 +78,19 @@ class BackendTests(WagtailTestUtils): # "JavaScript: The Definitive Guide" should be first self.assertEqual(results[0].title, "JavaScript: The Definitive Guide") + def test_annotate_score(self): + results = self.backend.search("JavaScript", models.Book).annotate_score('_score') + + for result in results: + self.assertIsInstance(result._score, float) + + def test_annotate_score_with_slice(self): + # #3431 - Annotate score wasn't being passed to new queryset when slicing + results = self.backend.search("JavaScript", models.Book).annotate_score('_score')[:10] + + for result in results: + self.assertIsInstance(result._score, float) + def test_search_and_operator(self): # Should not return "JavaScript: The good parts" as it does not have "Definitive" results = self.backend.search("JavaScript Definitive", models.Book, operator='and') diff --git a/wagtail/search/tests/test_db_backend.py b/wagtail/search/tests/test_db_backend.py index fba3332d7d..a9effc7dcc 100644 --- a/wagtail/search/tests/test_db_backend.py +++ b/wagtail/search/tests/test_db_backend.py @@ -13,6 +13,16 @@ class TestDBBackend(BackendTests, TestCase): def test_ranking(self): super().test_ranking() + # Doesn't support ranking + @unittest.expectedFailure + def test_annotate_score(self): + super().test_annotate_score() + + # Doesn't support ranking + @unittest.expectedFailure + def test_annotate_score_with_slice(self): + super().test_annotate_score_with_slice() + # Doesn't support ranking @unittest.expectedFailure def test_search_boosting_on_related_fields(self):