Ticket #22994: 22994-test.diff

File 22994-test.diff, 2.8 KB (added by Tim Graham, 10 years ago)
  • tests/admin_views/admin.py

    diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
    index 22ff453..e00cc69 100644
    a b from .models import (Article, Chapter, Child, Parent, Picture, Widget,  
    3535    UnchangeableObject, UserMessenger, Simple, Choice, ShortMessage, Telegram,
    3636    FilteredManager, EmptyModelHidden, EmptyModelVisible, EmptyModelMixin,
    3737    State, City, Restaurant, Worker, ParentWithDependentChildren,
    38     DependentChild, StumpJoke, FieldOverridePost)
     38    DependentChild, StumpJoke, FieldOverridePost, FunkyTag)
    3939
    4040
    4141def callable_year(dt_value):
    class RestaurantAdmin(admin.ModelAdmin):  
    827827        return {'name': 'overridden_value'}
    828828
    829829
     830class FunkyTagAdmin(admin.ModelAdmin):
     831    list_display = ('name', 'content_object')
     832
     833
    830834site = admin.AdminSite(name="admin")
    831835site.register(Article, ArticleAdmin)
    832836site.register(CustomArticle, CustomArticleAdmin)
    site.register(State, StateAdmin)  
    882886site.register(City, CityAdmin)
    883887site.register(Restaurant, RestaurantAdmin)
    884888site.register(Worker, WorkerAdmin)
     889site.register(FunkyTag, FunkyTagAdmin)
    885890
    886891# We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2.
    887892# That way we cover all four cases:
  • tests/admin_views/tests.py

    diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
    index 6006a0e..9b131fe 100644
    a b class AdminViewDeletedObjectsTest(TestCase):  
    17041704        """
    17051705        plot = Plot.objects.get(pk=3)
    17061706        FunkyTag.objects.create(content_object=plot, name='hott')
    1707         should_contain = """<li>Funky tag: hott"""
     1707        should_contain = """<li>Funky tag: <a href="/test_admin/admin/admin_views/funkytag/1/">hott"""
    17081708        response = self.client.get('/test_admin/admin/admin_views/plot/%s/delete/' % quote(3))
    17091709        self.assertContains(response, should_contain)
    17101710
    17111711
    17121712@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
    17131713    ROOT_URLCONF="admin_views.urls")
     1714class TestGenericRelations(TestCase):
     1715    fixtures = ['admin-views-users.xml', 'deleted-objects.xml']
     1716
     1717    def setUp(self):
     1718        self.client.login(username='super', password='secret')
     1719
     1720    def test_generic_content_object_in_list_display(self):
     1721        plot = Plot.objects.get(pk=3)
     1722        FunkyTag.objects.create(content_object=plot, name='hott')
     1723        response = self.client.get('/test_admin/admin/admin_views/funkytag/')
     1724        self.assertContains(response, "<td>%s</td>" % plot)
     1725
     1726
     1727@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
     1728    ROOT_URLCONF="admin_views.urls")
    17141729class AdminViewStringPrimaryKeyTest(TestCase):
    17151730    fixtures = ['admin-views-users.xml', 'string-primary-key.xml']
    17161731
Back to Top