forked from dj-stripe/dj-stripe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_admin.py
29 lines (21 loc) · 905 Bytes
/
test_admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
.. module:: dj-stripe.tests.test_admin
:synopsis: dj-stripe Admin Tests.
.. moduleauthor:: Oleksandr (@nanvel)
"""
import six
from django.contrib import admin
from django.test import TestCase
class TestAdminSite(TestCase):
def test_search_fields(self):
"""
Search for errors like this:
Bad search field <customer__user__username> for Customer model.
"""
for model, model_admin in six.iteritems(admin.site._registry):
for search_field in getattr(model_admin, 'search_fields', []):
model_name = model_admin.model.__name__
self.assertFalse(search_field.startswith('{table_name}__'.format(
table_name=model_name.lower())),
'Bad search field <{search_field}> for {model_name} model.'.format(
search_field=search_field, model_name=model_name))