MCPcopy
hub / github.com/django/django / test_check

Method test_check

tests/admin_views/tests.py:9338–9362  ·  view source on GitHub ↗

The view_on_site value is either a boolean or a callable

(self)

Source from the content-addressed store, hash-verified

9336 )
9337
9338 def test_check(self):
9339 "The view_on_site value is either a boolean or a callable"
9340 try:
9341 admin = CityAdmin(City, AdminSite())
9342 CityAdmin.view_on_site = True
9343 self.assertEqual(admin.check(), [])
9344 CityAdmin.view_on_site = False
9345 self.assertEqual(admin.check(), [])
9346 CityAdmin.view_on_site = lambda obj: obj.get_absolute_url()
9347 self.assertEqual(admin.check(), [])
9348 CityAdmin.view_on_site = []
9349 self.assertEqual(
9350 admin.check(),
9351 [
9352 Error(
9353 "The value of 'view_on_site' must be a callable or a boolean "
9354 "value.",
9355 obj=CityAdmin,
9356 id="admin.E025",
9357 ),
9358 ],
9359 )
9360 finally:
9361 # Restore the original values for the benefit of other tests.
9362 CityAdmin.view_on_site = True
9363
9364 def test_false(self):
9365 "The 'View on site' button is not displayed if view_on_site is False"

Callers

nothing calls this directly

Calls 5

AdminSiteClass · 0.90
ErrorClass · 0.90
CityAdminClass · 0.85
checkMethod · 0.45
get_absolute_urlMethod · 0.45

Tested by

no test coverage detected