The view_on_site value is either a boolean or a callable
(self)
| 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" |
nothing calls this directly
no test coverage detected