summaryrefslogtreecommitdiff
path: root/tests/admin_utils
diff options
context:
space:
mode:
Diffstat (limited to 'tests/admin_utils')
-rw-r--r--tests/admin_utils/models.py24
-rw-r--r--tests/admin_utils/test_logentry.py59
2 files changed, 1 insertions, 82 deletions
diff --git a/tests/admin_utils/models.py b/tests/admin_utils/models.py
index 8e812e27eb..243f314b03 100644
--- a/tests/admin_utils/models.py
+++ b/tests/admin_utils/models.py
@@ -1,5 +1,4 @@
from django.contrib import admin
-from django.contrib.admin.models import LogEntry, LogEntryManager
from django.db import models
from django.utils.translation import gettext_lazy as _
@@ -87,26 +86,3 @@ class VehicleMixin(Vehicle):
class Car(VehicleMixin):
pass
-
-
-class InheritedLogEntryManager(LogEntryManager):
- model = LogEntry
-
- def log_action(
- self,
- user_id,
- content_type_id,
- object_id,
- object_repr,
- action_flag,
- change_message="",
- ):
- return LogEntry.objects.create(
- user_id=user_id,
- content_type_id=content_type_id,
- object_id=str(object_id),
- # Changing actual repr to test repr
- object_repr="Test Repr",
- action_flag=action_flag,
- change_message=change_message,
- )
diff --git a/tests/admin_utils/test_logentry.py b/tests/admin_utils/test_logentry.py
index e97441eb2e..491a220199 100644
--- a/tests/admin_utils/test_logentry.py
+++ b/tests/admin_utils/test_logentry.py
@@ -8,10 +8,9 @@ from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import translation
-from django.utils.deprecation import RemovedInDjango60Warning
from django.utils.html import escape
-from .models import Article, ArticleProxy, Car, InheritedLogEntryManager, Site
+from .models import Article, ArticleProxy, Car, Site
@override_settings(ROOT_URLCONF="admin_utils.urls")
@@ -236,22 +235,6 @@ class LogEntryTests(TestCase):
logentry = LogEntry.objects.first()
self.assertEqual(repr(logentry), str(logentry.action_time))
- # RemovedInDjango60Warning.
- def test_log_action(self):
- msg = "LogEntryManager.log_action() is deprecated. Use log_actions() instead."
- content_type_val = ContentType.objects.get_for_model(Article).pk
- with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
- log_entry = LogEntry.objects.log_action(
- self.user.pk,
- content_type_val,
- self.a1.pk,
- repr(self.a1),
- CHANGE,
- change_message="Changed something else",
- )
- self.assertEqual(log_entry, LogEntry.objects.latest("id"))
- self.assertEqual(ctx.filename, __file__)
-
def test_log_actions(self):
queryset = Article.objects.all().order_by("-id")
msg = "Deleted Something"
@@ -289,46 +272,6 @@ class LogEntryTests(TestCase):
]
self.assertSequenceEqual(logs, expected_log_values)
- # RemovedInDjango60Warning.
- def test_log_action_fallback(self):
- LogEntry.objects2 = InheritedLogEntryManager()
- queryset = Article.objects.all().order_by("-id")
- content_type = ContentType.objects.get_for_model(self.a1)
- self.assertEqual(len(queryset), 3)
- msg = (
- "The usage of log_action() is deprecated. Implement log_actions() instead."
- )
- with (
- self.assertNumQueries(3),
- self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx,
- ):
- LogEntry.objects2.log_actions(self.user.pk, queryset, DELETION)
- self.assertEqual(ctx.filename, __file__)
- log_values = (
- LogEntry.objects.filter(action_flag=DELETION)
- .order_by("id")
- .values_list(
- "user",
- "content_type",
- "object_id",
- "object_repr",
- "action_flag",
- "change_message",
- )
- )
- expected_log_values = [
- (
- self.user.pk,
- content_type.id,
- str(obj.pk),
- "Test Repr",
- DELETION,
- "",
- )
- for obj in queryset
- ]
- self.assertSequenceEqual(log_values, expected_log_values)
-
def test_recentactions_without_content_type(self):
"""
If a LogEntry is missing content_type it will not display it in span