mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-14 02:03:11 +00:00
Fix test_delete for Elasticsearch
This commit is contained in:
parent
9d745541c8
commit
aefa7b5469
3 changed files with 9 additions and 18 deletions
|
|
@ -402,15 +402,17 @@ class BackendTests(WagtailTestUtils):
|
|||
self.assertSetEqual(results_across_pages, same_rank_objects)
|
||||
|
||||
def test_delete(self):
|
||||
# Delete foundation
|
||||
models.Book.objects.filter(title="Foundation").delete()
|
||||
foundation = models.Novel.objects.filter(title="Foundation").first()
|
||||
|
||||
# Refresh the index
|
||||
# Note: The delete signal handler should've removed the book, but we still need to refresh the index manually
|
||||
index = self.backend.get_index_for_model(models.Book)
|
||||
# Delete from the search index
|
||||
index = self.backend.get_index_for_model(models.Novel)
|
||||
if index:
|
||||
index.delete_item(foundation)
|
||||
index.refresh()
|
||||
|
||||
# Delete from the database
|
||||
foundation.delete()
|
||||
|
||||
# To test that the book was deleted from the index as well, we will perform the slicing check from an earlier
|
||||
# test where "Foundation" was the first result. We need to test it this way so we can pick up the case where
|
||||
# the object still exists in the index but not in the database (in that case, just two objects would be returned
|
||||
|
|
@ -423,9 +425,10 @@ class BackendTests(WagtailTestUtils):
|
|||
results = results[:3]
|
||||
|
||||
self.assertEqual(list(r.title for r in results), [
|
||||
# "Foundation"
|
||||
"The Hobbit",
|
||||
"The Two Towers",
|
||||
"The Fellowship of the Ring"
|
||||
"The Fellowship of the Ring" # If this item doesn't appear, "Foundation" is still in the index
|
||||
])
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import json
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
from django.db.models import Q
|
||||
|
|
@ -19,11 +18,6 @@ from .test_backends import BackendTests
|
|||
class TestElasticsearch2SearchBackend(BackendTests, ElasticsearchCommonSearchBackendTests, TestCase):
|
||||
backend_path = 'wagtail.search.backends.elasticsearch2'
|
||||
|
||||
# Broken
|
||||
@unittest.expectedFailure
|
||||
def test_delete(self):
|
||||
super(TestElasticsearch2SearchBackend, self).test_delete()
|
||||
|
||||
|
||||
class TestElasticsearch2SearchQuery(TestCase):
|
||||
def assertDictEqual(self, a, b):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import json
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
from django.db.models import Q
|
||||
|
|
@ -18,11 +17,6 @@ from .test_backends import BackendTests
|
|||
class TestElasticsearch5SearchBackend(BackendTests, ElasticsearchCommonSearchBackendTests, TestCase):
|
||||
backend_path = 'wagtail.search.backends.elasticsearch5'
|
||||
|
||||
# Broken
|
||||
@unittest.expectedFailure
|
||||
def test_delete(self):
|
||||
super(TestElasticsearch5SearchBackend, self).test_delete()
|
||||
|
||||
|
||||
class TestElasticsearch5SearchQuery(TestCase):
|
||||
def assertDictEqual(self, a, b):
|
||||
|
|
|
|||
Loading…
Reference in a new issue