本文整理汇总了Python中djblets.avatars.registry.AvatarServiceRegistry.unregister方法的典型用法代码示例。如果您正苦于以下问题:Python AvatarServiceRegistry.unregister方法的具体用法?Python AvatarServiceRegistry.unregister怎么用?Python AvatarServiceRegistry.unregister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类djblets.avatars.registry.AvatarServiceRegistry
的用法示例。
在下文中一共展示了AvatarServiceRegistry.unregister方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unregister
# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import unregister [as 别名]
def test_unregister(self):
"""Testing AvatarServiceRegistry.unregister"""
self.siteconfig.set(AvatarServiceRegistry.DEFAULT_SERVICE_KEY,
GravatarService.avatar_service_id)
self.siteconfig.set(AvatarServiceRegistry.ENABLED_SERVICES_KEY,
[GravatarService.avatar_service_id])
self.siteconfig.save()
registry = AvatarServiceRegistry()
gravatar_service = registry.get('avatar_service_id',
GravatarService.avatar_service_id)
self.assertEqual(registry.enabled_services, {gravatar_service})
registry.unregister(gravatar_service)
self.assertEqual(registry.enabled_services, set())
self.assertIsNone(registry.default_service)
siteconfig = SiteConfiguration.objects.get_current()
self.assertEqual(
siteconfig.get(AvatarServiceRegistry.ENABLED_SERVICES_KEY),
[GravatarService.avatar_service_id])
self.assertEqual(
siteconfig.get(AvatarServiceRegistry.DEFAULT_SERVICE_KEY),
GravatarService.avatar_service_id)
示例2: test_unregister
# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import unregister [as 别名]
def test_unregister(self):
"""Testing AvatarServiceRegistry.unregister"""
registry = AvatarServiceRegistry()
gravatar_service = registry.get('id', GravatarService.id)
registry.enable_service(GravatarService.id)
self.assertSetEqual(registry.enabled_services, {gravatar_service})
registry.unregister(gravatar_service)
self.assertSetEqual(registry.enabled_services, set())
示例3: test_unregister_register_keeps_enabled
# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import unregister [as 别名]
def test_unregister_register_keeps_enabled(self):
"""Testing AvatarServiceRegistry.unregister followed by register keeps
enabled state
"""
registry = AvatarServiceRegistry()
gravatar_service = registry.get('avatar_service_id',
GravatarService.avatar_service_id)
registry.enable_service(GravatarService)
self.assertEqual(registry.enabled_services, {gravatar_service})
registry.unregister(gravatar_service)
self.assertEqual(registry.enabled_services, set())
registry.register(gravatar_service)
self.assertEqual(registry.enabled_services, {gravatar_service})
siteconfig = SiteConfiguration.objects.get_current()
self.assertEqual(
siteconfig.get(AvatarServiceRegistry.ENABLED_SERVICES_KEY),
[GravatarService.avatar_service_id])