Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing admin tests when testing against Django's main branch #1140

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions simple_history/tests/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ def test_history_form_view_without_getting_history(self):
admin.history_form_view(request, poll.id, history.pk)

context = {
**admin_site.each_context(request),
# Verify this is set for original object
"original": poll,
"change_history": False,
Expand Down Expand Up @@ -484,7 +485,10 @@ def test_history_form_view_without_getting_history(self):
"save_on_top": admin.save_on_top,
"root_path": getattr(admin_site, "root_path", None),
}
context.update(admin_site.each_context(request))
# This key didn't exist prior to Django 4.2
if "log_entries" in context:
context["log_entries"] = ANY

mock_render.assert_called_once_with(
request, admin.object_history_form_template, context
)
Expand All @@ -509,6 +513,7 @@ def test_history_form_view_getting_history(self):
admin.history_form_view(request, poll.id, history.pk)

context = {
**admin_site.each_context(request),
# Verify this is set for history object not poll object
"original": history.instance,
"change_history": True,
Expand Down Expand Up @@ -538,7 +543,10 @@ def test_history_form_view_getting_history(self):
"save_on_top": admin.save_on_top,
"root_path": getattr(admin_site, "root_path", None),
}
context.update(admin_site.each_context(request))
# This key didn't exist prior to Django 4.2
if "log_entries" in context:
context["log_entries"] = ANY

mock_render.assert_called_once_with(
request, admin.object_history_form_template, context
)
Expand All @@ -563,6 +571,7 @@ def test_history_form_view_getting_history_with_setting_off(self):
admin.history_form_view(request, poll.id, history.pk)

context = {
**admin_site.each_context(request),
# Verify this is set for history object not poll object
"original": poll,
"change_history": False,
Expand Down Expand Up @@ -592,7 +601,10 @@ def test_history_form_view_getting_history_with_setting_off(self):
"save_on_top": admin.save_on_top,
"root_path": getattr(admin_site, "root_path", None),
}
context.update(admin_site.each_context(request))
# This key didn't exist prior to Django 4.2
if "log_entries" in context:
context["log_entries"] = ANY

mock_render.assert_called_once_with(
request, admin.object_history_form_template, context
)
Expand All @@ -617,6 +629,7 @@ def test_history_form_view_getting_history_abstract_external(self):
admin.history_form_view(request, obj.id, history.pk)

context = {
**admin_site.each_context(request),
# Verify this is set for history object
"original": history.instance,
"change_history": True,
Expand Down Expand Up @@ -648,7 +661,10 @@ def test_history_form_view_getting_history_abstract_external(self):
"save_on_top": admin.save_on_top,
"root_path": getattr(admin_site, "root_path", None),
}
context.update(admin_site.each_context(request))
# This key didn't exist prior to Django 4.2
if "log_entries" in context:
context["log_entries"] = ANY

mock_render.assert_called_once_with(
request, admin.object_history_form_template, context
)
Expand Down Expand Up @@ -676,6 +692,7 @@ def test_history_form_view_accepts_additional_context(self):
)

context = {
**admin_site.each_context(request),
# Verify this is set for original object
"anything_else": "will be merged into context",
"original": poll,
Expand Down Expand Up @@ -706,7 +723,10 @@ def test_history_form_view_accepts_additional_context(self):
"save_on_top": admin.save_on_top,
"root_path": getattr(admin_site, "root_path", None),
}
context.update(admin_site.each_context(request))
# This key didn't exist prior to Django 4.2
if "log_entries" in context:
context["log_entries"] = ANY

mock_render.assert_called_once_with(
request, admin.object_history_form_template, context
)
Expand Down