From 7b11422a550f29e36e3db5e3680f2b83a8b1bc8b Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Fri, 5 Jul 2024 12:47:10 +0100 Subject: [PATCH] Use a snippet model without RevisionMixin for testing EditingSession We want to make sure the feature works (without the new version detection) when using a snippet model that does not use RevisionMixin. We don't have any tests that ensures the new version detection works with a RevisionMixin-enabled snippet. We can add those later, but the code itself doesn't make a special-case between snippet vs pages, so it's probably okay to skip them. --- wagtail/admin/tests/test_editing_sessions.py | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/wagtail/admin/tests/test_editing_sessions.py b/wagtail/admin/tests/test_editing_sessions.py index 0e66548e33a1..5fa0aa914cd5 100644 --- a/wagtail/admin/tests/test_editing_sessions.py +++ b/wagtail/admin/tests/test_editing_sessions.py @@ -10,7 +10,7 @@ from wagtail.admin.models import EditingSession from wagtail.models import GroupPagePermission, Page -from wagtail.test.testapp.models import FullFeaturedSnippet, SimplePage +from wagtail.test.testapp.models import Advert, SimplePage from wagtail.test.utils import WagtailTestUtils if settings.USE_TZ: @@ -576,7 +576,7 @@ def test_user_must_have_edit_permission_on_page(self): @freeze_time(TIMESTAMP_NOW) def test_ping_snippet_model(self): - snippet = FullFeaturedSnippet.objects.create(text="Test snippet") + snippet = Advert.objects.create(text="Test snippet") # make user a member of Editors self.user.is_superuser = False @@ -585,12 +585,12 @@ def test_ping_snippet_model(self): self.user.groups.add(editors) editors.permissions.add( - Permission.objects.get(codename="change_fullfeaturedsnippet"), + Permission.objects.get(codename="change_advert"), ) session = EditingSession.objects.create( user=self.user, - content_type=ContentType.objects.get_for_model(FullFeaturedSnippet), + content_type=ContentType.objects.get_for_model(Advert), object_id=snippet.pk, last_seen_at=TIMESTAMP_1, ) @@ -598,14 +598,14 @@ def test_ping_snippet_model(self): # one record in the response EditingSession.objects.create( user=self.other_user, - content_type=ContentType.objects.get_for_model(FullFeaturedSnippet), + content_type=ContentType.objects.get_for_model(Advert), object_id=snippet.pk, last_seen_at=TIMESTAMP_2, is_editing=True, ) other_session_2 = EditingSession.objects.create( user=self.other_user, - content_type=ContentType.objects.get_for_model(FullFeaturedSnippet), + content_type=ContentType.objects.get_for_model(Advert), object_id=snippet.pk, last_seen_at=TIMESTAMP_3, is_editing=False, @@ -614,14 +614,14 @@ def test_ping_snippet_model(self): # session with last_seen_at too far in the past to be included in the response EditingSession.objects.create( user=self.other_user, - content_type=ContentType.objects.get_for_model(FullFeaturedSnippet), + content_type=ContentType.objects.get_for_model(Advert), object_id=snippet.pk, last_seen_at=TIMESTAMP_PAST, ) response = self.client.post( reverse( "wagtailadmin_editing_sessions:ping", - args=("tests", "fullfeaturedsnippet", str(snippet.pk), session.id), + args=("tests", "advert", str(snippet.pk), session.id), ) ) self.assertEqual(response.status_code, 200) @@ -644,7 +644,7 @@ def test_ping_snippet_model(self): self.assertFalse(session.is_editing) def test_ping_snippet_model_without_permission(self): - snippet = FullFeaturedSnippet.objects.create(text="Test snippet") + snippet = Advert.objects.create(text="Test snippet") # make user a member of Editors self.user.is_superuser = False @@ -654,14 +654,14 @@ def test_ping_snippet_model_without_permission(self): session = EditingSession.objects.create( user=self.user, - content_type=ContentType.objects.get_for_model(FullFeaturedSnippet), + content_type=ContentType.objects.get_for_model(Advert), object_id=snippet.pk, last_seen_at=TIMESTAMP_1, ) response = self.client.post( reverse( "wagtailadmin_editing_sessions:ping", - args=("tests", "fullfeaturedsnippet", str(snippet.pk), session.id), + args=("tests", "advert", str(snippet.pk), session.id), ) ) self.assertEqual(response.status_code, 404)