Skip to content

Instantly share code, notes, and snippets.

@dnozay
Created January 4, 2012 18:33
Show Gist options
  • Save dnozay/1561381 to your computer and use it in GitHub Desktop.
Save dnozay/1561381 to your computer and use it in GitHub Desktop.
AdminTestMixin for django testcases whose models expose admin interface.
# Mixin for checkin admin interface.
# To be used in a django testcase (using test client).
# e.g.
# from django.test import TestCase
# class EntryTest(AdminTestMixin, TestCase):
# pass
class AdminTestMixin(object):
def test_model_admin(self):
app_label = self.model._meta.app_label
name = self.model._meta.module_name
list_url = reverse('admin:%(app_label)s_%(name)s_changelist' % locals())
response = self.client.get(list_url)
self.assertEqual(response.status_code, 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment