diff --git a/tests/test_cms_toolbars.py b/tests/test_cms_toolbars.py index 08838e80..18b8bcbf 100644 --- a/tests/test_cms_toolbars.py +++ b/tests/test_cms_toolbars.py @@ -190,9 +190,11 @@ def test_add_edit_button_with_version_lock(self): toolbar.post_template_populate() if versioning_version < "2": - self.assertTrue(self._button_exists("Edit", toolbar.toolbar)) + self.assertTrue( + self._button_exists(lambda button: button.name.endswith("Edit"), toolbar.toolbar) + ) # Edit button should not be clickable - button = self._find_buttons("Edit", toolbar.toolbar) + button = self._find_buttons(lambda button: button.name.endswith("Edit"), toolbar.toolbar) self.assertTrue(button[0].disabled) else: self.assertFalse( diff --git a/tests/test_monkeypatch.py b/tests/test_monkeypatch.py index 4992a897..29b73e43 100644 --- a/tests/test_monkeypatch.py +++ b/tests/test_monkeypatch.py @@ -6,6 +6,7 @@ from cms.models import PageContent from cms.models.fields import PlaceholderRelationField +from djangocms_versioning import __version__ as versioning_version from djangocms_versioning import versionables from djangocms_versioning.admin import VersionAdmin from djangocms_versioning.constants import DRAFT, PUBLISHED @@ -42,8 +43,12 @@ def test_get_edit_link(self, mock_is_obj_review_locked): ) # We test that moderation check is called when getting an edit link self.assertTrue(mock_is_obj_review_locked.called) - # Edit link is removed as `mock_is_obj_review_locked` is True - self.assertEqual("", edit_link) + if versioning_version < "2": + # Edit link is inactive as `mock_is_obj_review_locked` is True + self.assertIn("inactive", edit_link) + else: + # Edit link is removed as `mock_is_obj_review_locked` is True + self.assertEqual("", edit_link) # self.assertIn("inactive", edit_link) @mock.patch("djangocms_moderation.monkeypatch.is_registered_for_moderation") @@ -79,7 +84,6 @@ def test_get_archive_link(self, _mock): args=(version.pk,), ) _mock.return_value = True - from djangocms_versioning import __version__ as versioning_version if versioning_version != "2.0.0": archive_link = self.version_admin._get_archive_link(version, self.mock_request) else: @@ -89,8 +93,12 @@ def test_get_archive_link(self, _mock): archive_link = "" # We test that moderation check is called when getting an edit link self.assertEqual(1, _mock.call_count) - # Edit link is unavailable - self.assertEqual("", archive_link) + if versioning_version < "2": + # Edit link is inactive as `mock_is_obj_review_locked` is True + self.assertIn("inactive", archive_link) + else: + # Edit link is unavailable + self.assertEqual("", archive_link) _mock.return_value = None archive_link = self.version_admin._get_archive_link(version, self.mock_request)