0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Test annotate_score on PostgreSQL search backend.

This commit is contained in:
Bertrand Bordage 2018-05-11 18:03:23 +02:00
parent 937254f321
commit 389835438c
3 changed files with 23 additions and 13 deletions

View File

@ -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)

View File

@ -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')

View File

@ -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):