Ticket #22418: 0001-Show-app_name-error-in-admin.patch

File 0001-Show-app_name-error-in-admin.patch, 3.2 KB (added by Vlastimil Zíma, 11 years ago)

Tests for custom app_name

  • tests/admin_views/admin.py

    From 2088a230d28b302b6adeacedb7b6bb704573a135 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Vlastimil=20Z=C3=ADma?= <vlastimil.zima@nic.cz>
    Date: Thu, 10 Apr 2014 16:33:36 +0200
    Subject: [PATCH] Show app_name error in admin
    
    ---
     tests/admin_views/admin.py |    5 +++++
     tests/admin_views/tests.py |   10 +++++++---
     tests/admin_views/urls.py  |    1 +
     3 files changed, 13 insertions(+), 3 deletions(-)
    
    diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
    index b31c5b5..5ce923d 100644
    a b site.register(Group, GroupAdmin)  
    786786site2 = admin.AdminSite(name="namespaced_admin")
    787787site2.register(User, UserAdmin)
    788788site2.register(Group, GroupAdmin)
     789
     790# Used to test URL application names
     791site3 = admin.AdminSite(app_name="custom_app", name="custom_name")
     792site3.register(User, UserAdmin)
     793site3.register(Group, GroupAdmin)
  • tests/admin_views/tests.py

    diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
    index f26b0ab..615f728 100644
    a b from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount,  
    5151    AdminOrderedModelMethod, AdminOrderedAdminMethod, AdminOrderedCallable,
    5252    Report, MainPrepopulated, RelatedPrepopulated, UnorderedObject,
    5353    Simple, UndeletableObject, Choice, ShortMessage, Telegram, Pizza, Topping)
    54 from .admin import site, site2
     54from .admin import site, site2, site3
    5555
    5656
    5757ERROR_MESSAGE = "Please enter the correct username and password \
    class AdminKeepChangeListFiltersTests(TestCase):  
    42564256        if user_id is None:
    42574257            user_id = self.get_sample_user_id()
    42584258        return "%s?%s" % (
    4259             reverse('admin:auth_user_change', args=(user_id,),
     4259            reverse('%s:auth_user_change' % self.admin_site.app_name, args=(user_id,),
    42604260                    current_app=self.admin_site.name),
    42614261            self.get_preserved_filters_querystring(),
    42624262        )
    class AdminKeepChangeListFiltersTests(TestCase):  
    42744274        if user_id is None:
    42754275            user_id = self.get_sample_user_id()
    42764276        return "%s?%s" % (
    4277             reverse('admin:auth_user_delete', args=(user_id,),
     4277            reverse('%s:auth_user_delete' % self.admin_site.app_name, args=(user_id,),
    42784278                    current_app=self.admin_site.name),
    42794279            self.get_preserved_filters_querystring(),
    42804280        )
    class NamespacedAdminKeepChangeListFiltersTests(AdminKeepChangeListFiltersTests)  
    43744374    admin_site = site2
    43754375
    43764376
     4377class CustomAppAdminKeepChangeListFiltersTests(AdminKeepChangeListFiltersTests):
     4378    admin_site = site3
     4379
     4380
    43774381class AdminGenericRelationTests(TestCase):
    43784382    def test_generic_relation_fk_list_filter(self):
    43794383        """
  • tests/admin_views/urls.py

    diff --git a/tests/admin_views/urls.py b/tests/admin_views/urls.py
    index 763c83a..25317ef 100644
    a b urlpatterns = patterns('',  
    1313    (r'^test_admin/admin3/', include(admin.site.urls), dict(form_url='pony')),
    1414    (r'^test_admin/admin4/', include(customadmin.simple_site.urls)),
    1515    (r'^test_admin/admin5/', include(admin.site2.urls)),
     16    (r'^test_admin/admin_custom_app/', include(admin.site3.urls)),
    1617)
Back to Top