From 5e14400768af12025083cde2b950709ca1d004c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=82=85=E7=9D=BF=E6=9B=BC?= Date: Wed, 30 Oct 2024 10:43:17 +0800 Subject: [PATCH] fix assert error for cms 4.0 --- tests/test_admin.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/test_admin.py b/tests/test_admin.py index 9ae803dcb..bc4be2241 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -40,10 +40,12 @@ from djangocms_navigation.compat import CMS_41 from .utils import UsefulAssertsMixin, disable_versioning_for_navigation +versioning_substr = "" if CMS_41: from cms.api import create_page_content # noqa: F401 else: from cms.api import create_title as create_page_content # noqa: F401 + versioning_substr = "-versioning" class MenuItemChangelistTestCase(CMSTestCase): @@ -227,14 +229,15 @@ def test_list_display_without_version_locking(self): list_display[0:4], ["title", "get_author", "get_modified_date", "get_versioning_state"] ) - self.assertIn("cms-action-btn", list_display[-1]) + + self.assertIn(f"cms{versioning_substr}-action-btn", list_display[-1]) # The preview button is present - self.assertIn("cms-action-preview", list_display[-1]) + self.assertIn(f"cms{versioning_substr}-action-preview", list_display[-1]) # The edit button is present - self.assertIn("cms-action-edit", list_display[-1]) + self.assertIn(f"cms{versioning_substr}-action-edit", list_display[-1]) self.assertIn("cms-form-get-method", list_display[-1]) - self.assertIn("js-action", list_display[-1]) - self.assertIn("js-keep-sideframe", list_display[-1]) + self.assertIn(f"js{versioning_substr}-action", list_display[-1]) + self.assertIn(f"js{versioning_substr}-keep-sideframe", list_display[-1]) @override_settings(DJANGOCMS_NAVIGATION_VERSIONING_ENABLED=False) @disable_versioning_for_navigation() @@ -2019,7 +2022,7 @@ def test_preview_link(self): func = self.modeladmin._list_actions(self.get_request("/admin")) response = func(menu_content) - self.assertIn("cms-action-preview", response) + self.assertIn(f"cms{versioning_substr}-action-preview", response) self.assertIn('title="Preview"', response) self.assertIn(preview_endpoint, response) @@ -2034,7 +2037,7 @@ def test_edit_link(self): edit_endpoint = reverse("admin:djangocms_versioning_menucontentversion_edit_redirect", args=(version.pk,),) response = func(menu_content) - self.assertIn("cms-action-btn", response) + self.assertIn(f"cms{versioning_substr}-action-btn", response) self.assertIn('title="Edit"', response) self.assertIn(edit_endpoint, response) @@ -2078,7 +2081,7 @@ def test_edit_link(self): ) response = func(menu_content.root) - self.assertIn("cms-action-btn", response) + self.assertIn(f"cms{versioning_substr}-action-btn", response) self.assertIn('title="Edit"', response) self.assertIn(edit_endpoint, response)