本文整理汇总了Python中django.contrib.admin.sites.AdminSite.overview方法的典型用法代码示例。如果您正苦于以下问题:Python AdminSite.overview方法的具体用法?Python AdminSite.overview怎么用?Python AdminSite.overview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.admin.sites.AdminSite
的用法示例。
在下文中一共展示了AdminSite.overview方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StatsAdminTests
# 需要导入模块: from django.contrib.admin.sites import AdminSite [as 别名]
# 或者: from django.contrib.admin.sites.AdminSite import overview [as 别名]
class StatsAdminTests(TestCase):
def setUp(self):
self.admin_site = AdminSite()
patch_admin(self.admin_site)
self.factory = RequestFactory()
def test_modelstats_overview_called(self):
"""Test that the overview function on the ModelStats object is called
by the overview function on the admin site.
"""
class TestModelStats(ModelStats):
slug = 'unique_slug'
self.admin_site.register_stats(TestModel, TestModelStats)
with patch.object(TestModelStats, 'overview') as overview:
eq_(overview.called, False)
self.admin_site.overview(self.factory.get('/test'), 'unique_slug')
eq_(overview.called, True)
def test_unique_slugs(self):
"""Test that the admin site generates unique slugs for multiple
ModelStats that have identical slugs.
"""
class TestModelStats(ModelStats):
slug = 'unique_slug'
self.admin_site.register_stats(TestModel, TestModelStats)
class TestModelStats2(ModelStats):
slug = 'unique_slug'
self.admin_site.register_stats(TestModel, TestModelStats2)
# If slugs were identical, there would be only 1 stat here.
eq_(len(self.admin_site.stats), 2)