From 8cf2c14619b3cac953f5e355a269dca36aeabc0f Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Thu, 19 Oct 2017 16:58:13 +0100 Subject: [PATCH] Update test_single_result to use custom ordering For consistency with other slicing tests --- .../contrib/postgres_search/tests/test_backend.py | 5 ----- wagtail/wagtailsearch/tests/test_backends.py | 12 +++--------- wagtail/wagtailsearch/tests/test_db_backend.py | 5 ----- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/wagtail/contrib/postgres_search/tests/test_backend.py b/wagtail/contrib/postgres_search/tests/test_backend.py index e1acebbafc..6b490e31f9 100644 --- a/wagtail/contrib/postgres_search/tests/test_backend.py +++ b/wagtail/contrib/postgres_search/tests/test_backend.py @@ -56,8 +56,3 @@ class TestPostgresSearchBackend(BackendTests, TestCase): @unittest.expectedFailure def test_order_by_non_filterable_field(self): super(TestPostgresSearchBackend, self).test_order_by_non_filterable_field() - - # Broken - @unittest.expectedFailure - def test_single_result(self): - super(TestPostgresSearchBackend, self).test_single_result() diff --git a/wagtail/wagtailsearch/tests/test_backends.py b/wagtail/wagtailsearch/tests/test_backends.py index d0ea504625..f29b965e89 100644 --- a/wagtail/wagtailsearch/tests/test_backends.py +++ b/wagtail/wagtailsearch/tests/test_backends.py @@ -331,16 +331,10 @@ class BackendTests(WagtailTestUtils): # SLICING TESTS def test_single_result(self): - # Note: different to test_ranking as that casts the results to the list before doing a key lookup - # This test sends the key IDs back into Elasticsearch, performing two separate queries - results = self.backend.search("JavaScript Definitive", models.Book, operator='or') - self.assertEqual(set(r.title for r in results), { - "JavaScript: The good parts", - "JavaScript: The Definitive Guide" - }) + results = self.backend.search(None, models.Novel.objects.order_by('number_of_pages'), order_by_relevance=False) - self.assertEqual(results[0].title, "JavaScript: The Definitive Guide") - self.assertEqual(results[1].title, "JavaScript: The good parts") + self.assertEqual(results[0].title, "Foundation") + self.assertEqual(results[1].title, "The Hobbit") def test_limit(self): # Note: we need consistant ordering for this test diff --git a/wagtail/wagtailsearch/tests/test_db_backend.py b/wagtail/wagtailsearch/tests/test_db_backend.py index 0782d174b2..5344bac775 100644 --- a/wagtail/wagtailsearch/tests/test_db_backend.py +++ b/wagtail/wagtailsearch/tests/test_db_backend.py @@ -40,11 +40,6 @@ class TestDBBackend(BackendTests, TestCase): def test_order_by_non_filterable_field(self): super(TestDBBackend, self).test_order_by_non_filterable_field() - # Broken - @unittest.expectedFailure - def test_single_result(self): - super(TestDBBackend, self).test_single_result() - # Doesn't support the index API used in this test @unittest.expectedFailure def test_same_rank_pages(self):