Repository: torchbox/wagtailmedia (language: python)

Issue:
Fix tests for 2.15rc1
wagtail.search is missing from INSTALLED_APPS in the test settings file, which fails in 2.15rc1 as the new default search backend has its own models.

(This error will probably go away if we go ahead with https://github.com/wagtail/wagtail/issues/7633 and change the default back to wagtail.search.backends.db, but having this in INSTALLED_APPS is probably a good thing either way)


Discussion / hints:

Fix patch:
diff --git a/src/wagtailmedia/models.py b/src/wagtailmedia/models.py
index 5cdceede..1562c965 100644
--- a/src/wagtailmedia/models.py
+++ b/src/wagtailmedia/models.py
@@ -71,6 +71,7 @@ class AbstractMedia(CollectionMember, index.Indexed, models.Model):
 
     search_fields = CollectionMember.search_fields + [
         index.SearchField("title", partial_match=True, boost=10),
+        index.FilterField("title"),
         index.RelatedFields(
             "tags",
             [


Test patch:
diff --git a/tests/settings.py b/tests/settings.py
index c8b5b8c6..837f7dc1 100644
--- a/tests/settings.py
+++ b/tests/settings.py
@@ -74,6 +74,7 @@
     "django.contrib.sessions",
     "django.contrib.staticfiles",
     "wagtail.contrib.redirects",
+    "wagtail.contrib.search_promotions",
     "wagtail.images",
     "wagtail.users",
     "wagtail.documents",
diff --git a/tests/test_models.py b/tests/test_models.py
index 2bdcd97c..030906c4 100644
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -144,9 +144,13 @@ def test_custom_ordering(self):
         aaa_media = Media.objects.create(title="AAA Test media", duration=100)
         zzz_media = Media.objects.create(title="ZZZ Test media", duration=100)
 
-        results = Media.objects.order_by("title").search("Test")
+        results = Media.objects.order_by("title").search(
+            "Test", order_by_relevance=False
+        )
         self.assertEqual(list(results), [aaa_media, zzz_media])
-        results = Media.objects.order_by("-title").search("Test")
+        results = Media.objects.order_by("-title").search(
+            "Test", order_by_relevance=False
+        )
         self.assertEqual(list(results), [zzz_media, aaa_media])
 
     def _test_form_init_with_non_editable_field(self, media_type, field_name):