0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Add failing test

This commit is contained in:
Andy Babic 2021-01-30 19:28:46 +00:00 committed by Matt Westcott
parent 4151b8ae21
commit 9e717ced1d

View File

@ -1,3 +1,5 @@
import pickle
from django.test import TestCase, override_settings
from wagtail.models import Site
@ -51,6 +53,35 @@ class SettingModelTestCase(SiteSettingsTestMixin, TestCase):
privacy_policy_page=self.other_site.root_page,
)
def test_importantpages_object_is_pickleable(self):
obj = self._create_importantpagessitesetting_object()
# Triggers creation of the InvokeViaAttributeShortcut instance,
# and also gives us a value we can use for comparisson
signup_page_url = obj.page_url.sign_up_page
# Attempt to pickle ImportantPages instance
try:
pickled = pickle.dumps(obj, -1)
except Exception as e:
raise AssertionError(
"An error occured when attempting to pickle %r: %s" % (obj, e)
)
# Now unpickle the pickled ImportantPages
try:
unpickled = pickle.loads(pickled)
except Exception as e:
raise AssertionError(
"An error occured when attempting to unpickle %r: %s" % (obj, e)
)
# Using 'page_url' should create a new InvokeViaAttributeShortcut
# instance, which should give the same result as the original
self.assertEqual(
unpickled.page_url.sign_up_page,
signup_page_url,
)
def test_select_related(self, expected_queries=4):
"""The `select_related` attribute on setting models is `None` by default, so fetching foreign keys values requires additional queries"""
request = self.get_request()