当前位置: 首页>>代码示例>>Python>>正文


Python AvatarServiceRegistry.get方法代码示例

本文整理汇总了Python中djblets.avatars.registry.AvatarServiceRegistry.get方法的典型用法代码示例。如果您正苦于以下问题:Python AvatarServiceRegistry.get方法的具体用法?Python AvatarServiceRegistry.get怎么用?Python AvatarServiceRegistry.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在djblets.avatars.registry.AvatarServiceRegistry的用法示例。


在下文中一共展示了AvatarServiceRegistry.get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_unregister

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [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)
开发者ID:chipx86,项目名称:djblets,代码行数:27,代码来源:tests.py

示例2: test_disable_default_from_setter

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [as 别名]
    def test_disable_default_from_setter(self):
        """Testing AvatarServiceRegistry.enabled_services setter unsets the
        default services
        """
        registry = AvatarServiceRegistry()
        registry.enable_service(GravatarService.id)
        registry.set_default_service(registry.get('id', GravatarService.id))

        registry.enabled_services = []
        self.assertIsNone(registry.default_service)
开发者ID:iconoeugen,项目名称:djblets,代码行数:12,代码来源:tests.py

示例3: test_disable_default

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [as 别名]
    def test_disable_default(self):
        """Testing AvatarServiceRegistry.disable_service unsets the default
        service
        """
        registry = AvatarServiceRegistry()
        registry.enable_service(GravatarService.id)
        registry.set_default_service(registry.get('id', GravatarService.id))

        registry.disable_service(GravatarService.id)
        self.assertIsNone(registry.default_service)
开发者ID:iconoeugen,项目名称:djblets,代码行数:12,代码来源:tests.py

示例4: test_unregister

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [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())
开发者ID:iconoeugen,项目名称:djblets,代码行数:12,代码来源:tests.py

示例5: test_set_default_service_disabled

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [as 别名]
    def test_set_default_service_disabled(self):
        """Testing AvatarServiceRegistry.set_default_service setter with a
        disabled service
        """
        registry = AvatarServiceRegistry()
        gravatar_service = registry.get('id', GravatarService.id)

        self.assertIsNone(registry.default_service)

        with self.assertRaises(DisabledServiceError):
            registry.set_default_service(gravatar_service)

        self.assertIsNone(registry.default_service)
开发者ID:iconoeugen,项目名称:djblets,代码行数:15,代码来源:tests.py

示例6: test_set_enabled_services

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [as 别名]
    def test_set_enabled_services(self):
        """Testing AvatarServiceRegistry.enabled_services setter"""
        registry = AvatarServiceRegistry()

        dummy_service = DummyAvatarService()
        registry.register(dummy_service)

        gravatar_service = registry.get('id', GravatarService.id)

        registry.enabled_services = [dummy_service, gravatar_service]

        self.assertEqual(registry.enabled_services,
                         {dummy_service, gravatar_service})
开发者ID:iconoeugen,项目名称:djblets,代码行数:15,代码来源:tests.py

示例7: test_set_enabled_services_invalid_service

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [as 别名]
    def test_set_enabled_services_invalid_service(self):
        """Testing AvatarServiceRegistry.enabled_services setter with an
        unregistered service
        """
        registry = AvatarServiceRegistry()

        dummy_service = DummyAvatarService()

        gravatar_service = registry.get('id', GravatarService.id)

        with self.assertRaises(ItemLookupError):
            registry.enabled_services = [dummy_service, gravatar_service]

        self.assertEqual(registry.enabled_services, set())
开发者ID:iconoeugen,项目名称:djblets,代码行数:16,代码来源:tests.py

示例8: test_set_default_service_disabled

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [as 别名]
    def test_set_default_service_disabled(self):
        """Testing AvatarServiceRegistry.set_default_service with a disabled
        service
        """
        registry = AvatarServiceRegistry()
        gravatar_service = registry.get('avatar_service_id',
                                        GravatarService.avatar_service_id)

        self.assertIsNone(registry.default_service)

        with self.assertRaises(DisabledServiceError):
            registry.set_default_service(gravatar_service)

        self.assertIsNone(registry.default_service)

        siteconfig = SiteConfiguration.objects.get_current()
        self.assertIsNone(
            siteconfig.get(AvatarServiceRegistry.DEFAULT_SERVICE_KEY))
开发者ID:chipx86,项目名称:djblets,代码行数:20,代码来源:tests.py

示例9: test_default_service

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [as 别名]
    def test_default_service(self):
        """Testing AvatarServiceRegistry.default_service"""
        registry = AvatarServiceRegistry()

        dummy_serivce = DummyAvatarService()
        gravatar_service = registry.get('id', GravatarService.id)
        registry.register(dummy_serivce)
        registry.enabled_services = [dummy_serivce, gravatar_service]

        self.assertIsNone(registry.default_service)

        registry.set_default_service(dummy_serivce)
        self.assertEqual(registry.default_service, dummy_serivce)

        registry.set_default_service(gravatar_service)
        self.assertEqual(registry.default_service, gravatar_service)

        registry.set_default_service(None)
        self.assertIsNone(registry.default_service)
开发者ID:iconoeugen,项目名称:djblets,代码行数:21,代码来源:tests.py

示例10: test_unregister_register_keeps_enabled

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [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])
开发者ID:chipx86,项目名称:djblets,代码行数:23,代码来源:tests.py

示例11: test_populate

# 需要导入模块: from djblets.avatars.registry import AvatarServiceRegistry [as 别名]
# 或者: from djblets.avatars.registry.AvatarServiceRegistry import get [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)
开发者ID:iconoeugen,项目名称:djblets,代码行数:24,代码来源:tests.py


注:本文中的djblets.avatars.registry.AvatarServiceRegistry.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。