예제 #1
0
 def test_level_limit_not_set_do_move_any_level_allowed(self):
     """
     Testing if when the level_limit attribute is not set the do_move method should allow anything.
     """
     item_admin = ItemAdmin(TestItem, self.site)
     instance = item_admin.get_object(request, self.menu_child.id)
     parent_instance = item_admin.get_object(request, self.menu_parent.id)
     item_admin.do_move(instance, "inside", parent_instance)
     self.assertEqual(instance.parent, parent_instance)
예제 #2
0
 def test_level_limit_set_do_move_filters_level_allowed(self):
     """
     Testing if when the level_limit attribute is set the move_to method should not allow exceeding it.
     """
     item_admin = ItemAdmin(TestItem, self.site)
     item_admin.level_limit = 0
     instance = item_admin.get_object(request, self.menu_child.id)
     parent_instance = item_admin.get_object(request, self.menu_parent.id)
     with self.assertRaises(Exception):
         item_admin.do_move(instance, "inside", parent_instance)