Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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())
Ejemplo n.º 4
0
    def test_unregister(self):
        """Testing AvatarServiceRegistry.unregister"""
        registry = AvatarServiceRegistry()
        gravatar_service = registry.get('avatar_service_id',
                                        GravatarService.avatar_service_id)

        registry.enable_service(GravatarService)

        self.assertSetEqual(registry.enabled_services, {gravatar_service})
        registry.unregister(gravatar_service)
        self.assertSetEqual(registry.enabled_services, set())
Ejemplo n.º 5
0
    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])
Ejemplo n.º 6
0
    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])