From 26b0a827cdc7011cd32070cb9dd07fc0665ce76c Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 28 Jan 2015 09:54:42 +0000 Subject: [PATCH] Added failing test for #937 --- .../tests/test_elasticsearch_backend.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/wagtail/wagtailsearch/tests/test_elasticsearch_backend.py b/wagtail/wagtailsearch/tests/test_elasticsearch_backend.py index b612f1ce3..f98d0bb94 100644 --- a/wagtail/wagtailsearch/tests/test_elasticsearch_backend.py +++ b/wagtail/wagtailsearch/tests/test_elasticsearch_backend.py @@ -135,6 +135,35 @@ class TestElasticSearchBackend(BackendTests, TestCase): # Even though they both start with the letter "H". This should not be considered a match self.assertEqual(len(results), 0) + @unittest.expectedFailure + def test_search_with_hyphen(self): + """ + This tests that punctuation characters are treated the same + way in both indexing and querying. + + See: https://github.com/torchbox/wagtail/issues/937 + """ + # Reset the index + self.backend.reset_index() + self.backend.add_type(models.SearchTest) + self.backend.add_type(models.SearchTestChild) + + # Add some test data + obj = models.SearchTest() + obj.title = "Hello-World" + obj.live = True + obj.save() + self.backend.add(obj) + + # Refresh the index + self.backend.refresh_index() + + # Test search for "Hello-World" + results = self.backend.search("Hello-World", models.SearchTest.objects.all()) + + # Should find the result + self.assertEqual(len(results), 1) + class TestElasticSearchQuery(TestCase): def assertDictEqual(self, a, b):