本文整理汇总了Python中djblets.avatars.registry.AvatarServiceRegistry.populate方法的典型用法代码示例。如果您正苦于以下问题:Python AvatarServiceRegistry.populate方法的具体用法?Python AvatarServiceRegistry.populate怎么用?Python AvatarServiceRegistry.populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类djblets.avatars.registry.AvatarServiceRegistry
的用法示例。
在下文中一共展示了AvatarServiceRegistry.populate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_default_service_after_service_reregistered
# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import populate [as 别名]
def test_default_service_after_service_reregistered(self):
"""Testing AvatarServiceRegistry.default_service after service
registered after previously unregistered
"""
self.siteconfig.set(AvatarServiceRegistry.ENABLED_SERVICES_KEY,
[DummyAvatarService.avatar_service_id])
self.siteconfig.set(AvatarServiceRegistry.DEFAULT_SERVICE_KEY,
DummyAvatarService.avatar_service_id)
self.siteconfig.save()
registry = AvatarServiceRegistry()
registry.populate()
self.assertIsNone(registry.default_service)
# Make sure it's still saved in siteconfig. We'd only unset it if
# wasn't in the list of stoerd enabled service IDs, since we might be
# running without extensions loaded.
siteconfig = SiteConfiguration.objects.get_current()
self.assertEqual(
siteconfig.get(AvatarServiceRegistry.DEFAULT_SERVICE_KEY),
DummyAvatarService.avatar_service_id)
registry.register(DummyAvatarService)
self.assertIsInstance(registry.default_service, DummyAvatarService)
siteconfig = SiteConfiguration.objects.get_current()
self.assertEqual(
siteconfig.get(AvatarServiceRegistry.DEFAULT_SERVICE_KEY),
DummyAvatarService.avatar_service_id)
示例2: test_populate
# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import populate [as 别名]
def test_populate(self):
"""Testing AvatarServiceRegistry.populate with site configuration
settings
"""
self.siteconfig.set(AvatarServiceRegistry.ENABLED_SERVICES_KEY,
[GravatarService.avatar_service_id])
self.siteconfig.set(AvatarServiceRegistry.DEFAULT_SERVICE_KEY,
GravatarService.avatar_service_id)
self.siteconfig.save()
registry = AvatarServiceRegistry()
registry.populate()
self.assertTrue(registry.populated)
self.assertIsInstance(registry.default_service, GravatarService)
self.assertEqual(registry.enabled_services, {GravatarService})
示例3: test_populate
# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import populate [as 别名]
def test_populate(self):
"""Testing AvatarServiceRegistry.populate with site configuration
settings
"""
self.spy_on(logging.error)
self.siteconfig.set(AvatarServiceRegistry.ENABLED_SERVICES_KEY,
[GravatarService.id])
self.siteconfig.set(AvatarServiceRegistry.DEFAULT_SERVICE_KEY,
GravatarService.id)
self.siteconfig.save()
registry = AvatarServiceRegistry()
registry.populate()
gravatar_service = registry.get('id', GravatarService.id)
self.assertTrue(registry.populated)
self.assertEqual(registry.default_service, gravatar_service)
self.assertEqual(registry.enabled_services, {gravatar_service})
self.assertFalse(logging.error.spy.called)