diff --git a/tests/test_admin.py b/tests/test_admin.py index c90133d9f..9ae803dcb 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -9,6 +9,7 @@ from django.contrib import admin +from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.contrib.messages import get_messages from django.contrib.sites.models import Site @@ -1377,6 +1378,16 @@ def test_menuitem_delete_view_item_with_children(self): content ) + def get_permission(self, codename): + _list = codename.split('.') + app_label = '' + if len(_list) > 1: + app_label = _list[0] + codename = _list[1] + return Permission.objects.get(codename=codename, content_type__app_label=app_label) + else: + return Permission.objects.get(codename=codename) + def test_menuitem_delete_view_with_permission(self): """ With appropriate permissions, the delete view allows deletion of Menuitems @@ -1385,14 +1396,17 @@ def test_menuitem_delete_view_with_permission(self): "user_with_delete", is_staff=True ) menu_content = factories.MenuContentWithVersionFactory(version__created_by=user_with_delete_permissions) - child = factories.ChildMenuItemFactory(parent=menu_content.root) - new_child = factories.ChildMenuItemFactory(parent=menu_content.root) - child_of_child = factories.ChildMenuItemFactory(parent=child) - factories.ChildMenuItemFactory(parent=child_of_child) + child = factories.ChildMenuItemFactory(title="child", parent=menu_content.root) + new_child = factories.ChildMenuItemFactory(title="new_child", parent=menu_content.root) + child_of_child = factories.ChildMenuItemFactory(title="child_of_child", parent=child) + factories.ChildMenuItemFactory(title="child_of_child_2", parent=child_of_child) self.add_permission(user_with_delete_permissions, "view_menucontentversion") self.add_permission(user_with_delete_permissions, "delete_menuitem") + if CMS_41: + self.add_permission(user_with_delete_permissions, "djangocms_versioning.delete_versionlock") + # Delete one, editable node, with no children delete_url_single = reverse( "admin:djangocms_navigation_menuitem_delete", args=(menu_content.id, new_child.id,)