diff options
author | Anton Samarchyan <anton.samarchyan@savoirfairelinux.com> | 2017-06-02 18:44:34 -0400 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-06-02 18:47:07 -0400 |
commit | 2b53c8377dcb7270d95db0b3ea8b2cb28550c5a8 (patch) | |
tree | 548b035895c3796bdca4c077bfe9d99330af34c7 /tests/admin_checks | |
parent | 7c9a83330169df1118f6bd690aed131e7c59638d (diff) | |
download | django-2b53c8377dcb7270d95db0b3ea8b2cb28550c5a8.tar.gz |
Improved test coverage of contrib/admin/checks.py.
Diffstat (limited to 'tests/admin_checks')
-rw-r--r-- | tests/admin_checks/tests.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py index 5419fc1009..eb394f794f 100644 --- a/tests/admin_checks/tests.py +++ b/tests/admin_checks/tests.py @@ -64,6 +64,10 @@ class SystemChecksTestCase(SimpleTestCase): ] self.assertEqual(errors, expected) + @override_settings(TEMPLATES=[]) + def test_no_template_engines(self): + self.assertEqual(admin.checks.check_dependencies(), []) + @override_settings( INSTALLED_APPS=[ 'django.contrib.admin', @@ -138,6 +142,31 @@ class SystemChecksTestCase(SimpleTestCase): ] self.assertEqual(errors, expected) + def test_list_editable_not_a_list_or_tuple(self): + class SongAdmin(admin.ModelAdmin): + list_editable = 'test' + + self.assertEqual(SongAdmin(Song, AdminSite()).check(), [ + checks.Error( + "The value of 'list_editable' must be a list or tuple.", + obj=SongAdmin, + id='admin.E120', + ) + ]) + + def test_list_editable_missing_field(self): + class SongAdmin(admin.ModelAdmin): + list_editable = ('test',) + + self.assertEqual(SongAdmin(Song, AdminSite()).check(), [ + checks.Error( + "The value of 'list_editable[0]' refers to 'test', which is " + "not an attribute of 'admin_checks.Song'.", + obj=SongAdmin, + id='admin.E121', + ) + ]) + def test_readonly_and_editable(self): class SongAdmin(admin.ModelAdmin): readonly_fields = ["original_release"] @@ -572,6 +601,18 @@ class SystemChecksTestCase(SimpleTestCase): ] self.assertEqual(errors, expected) + def test_readonly_fields_not_list_or_tuple(self): + class SongAdmin(admin.ModelAdmin): + readonly_fields = 'test' + + self.assertEqual(SongAdmin(Song, AdminSite()).check(), [ + checks.Error( + "The value of 'readonly_fields' must be a list or tuple.", + obj=SongAdmin, + id='admin.E034', + ) + ]) + def test_extra(self): class SongAdmin(admin.ModelAdmin): def awesome_song(self, instance): |