本文整理汇总了Python中djblets.integrations.manager.IntegrationManager.register_integration_class方法的典型用法代码示例。如果您正苦于以下问题:Python IntegrationManager.register_integration_class方法的具体用法?Python IntegrationManager.register_integration_class怎么用?Python IntegrationManager.register_integration_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类djblets.integrations.manager.IntegrationManager
的用法示例。
在下文中一共展示了IntegrationManager.register_integration_class方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_check_expired_when_expired
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_check_expired_when_expired(self):
"""Testing IntegrationManager.check_expired when expired"""
manager = IntegrationManager(IntegrationConfig)
# Cache some state.
integration1 = manager.register_integration_class(DummyIntegration1)
integration1.create_config(enabled=True, save=True)
manager.get_integration_configs(DummyIntegration1)
integration2 = manager.register_integration_class(DummyIntegration2)
manager.get_integration_configs(DummyIntegration1)
# Make sure the integration isn't enabled. This would be because we
# haven't refreshed yet.
self.assertFalse(integration1.enabled)
self.assertFalse(integration2.enabled)
self.assertNotEqual(manager._integration_configs, {})
# Check expired state.
self.assertTrue(manager.is_expired())
manager.check_expired()
# Make sure state has been updated and caches cleared.
self.assertTrue(integration1.enabled)
self.assertFalse(integration2.enabled)
self.assertEqual(manager._integration_configs, {})
示例2: test_get_integration_classes
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_get_integration_classes(self):
"""Testing IntegrationManager.get_integration_classes"""
manager = IntegrationManager(IntegrationConfig)
manager.register_integration_class(DummyIntegration1)
manager.register_integration_class(DummyIntegration2)
classes = manager.get_integration_classes()
self.assertEqual(set(classes), {DummyIntegration1, DummyIntegration2})
示例3: test_register_integration_class_with_construct_error
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_register_integration_class_with_construct_error(self):
"""Testing IntegrationManager.register_integration_class with
construction error
"""
manager = IntegrationManager(IntegrationConfig)
with self.assertRaises(IntegrationRegistrationError):
manager.register_integration_class(BrokenIntegration)
示例4: test_register_integration_class_with_already_registered
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_register_integration_class_with_already_registered(self):
"""Testing IntegrationManager.register_integration_class with
already registered class
"""
manager = IntegrationManager(IntegrationConfig)
manager.register_integration_class(DummyIntegration1)
with self.assertRaises(IntegrationAlreadyRegisteredError):
manager.register_integration_class(DummyIntegration1)
示例5: test_unregister_integration_class
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_unregister_integration_class(self):
"""Testing IntegrationManager.unregister_integration_class"""
manager = IntegrationManager(IntegrationConfig)
manager.register_integration_class(DummyIntegration1)
manager.unregister_integration_class(DummyIntegration1)
integration_id = DummyIntegration1.integration_id
self.assertNotIn(integration_id, manager._integration_classes)
self.assertNotIn(integration_id, manager._integration_instances)
示例6: test_get_integration
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_get_integration(self):
"""Testing IntegrationManager.get_integration"""
manager = IntegrationManager(IntegrationConfig)
manager.register_integration_class(DummyIntegration1)
manager.register_integration_class(DummyIntegration2)
integration = manager.get_integration(DummyIntegration1.integration_id)
self.assertEqual(integration.__class__, DummyIntegration1)
integration = manager.get_integration(DummyIntegration2.integration_id)
self.assertEqual(integration.__class__, DummyIntegration2)
示例7: test_check_expired_when_not_expired
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_check_expired_when_not_expired(self):
"""Testing IntegrationManager.check_expired when not expired"""
manager = IntegrationManager(IntegrationConfig)
# Cache some state.
integration = manager.register_integration_class(DummyIntegration1)
integration.create_config(enabled=True, save=True)
manager.get_integration_configs(DummyIntegration1)
# Make sure the integration isn't enabled. This would be because we
# haven't refreshed yet.
self.assertFalse(integration.enabled)
self.assertNotEqual(manager._integration_configs, {})
# Fake having the latest state.
manager._needs_recalc = False
# Check expired state, without actually expiring it.
self.assertFalse(manager.is_expired())
manager.check_expired()
# Make sure state has not changed.
self.assertFalse(manager.is_expired())
self.assertFalse(integration.enabled)
self.assertNotEqual(manager._integration_configs, {})
示例8: IntegrationConfigTests
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
class IntegrationConfigTests(IntegrationsTestCase):
"""Unit tests for djblets.integrations.models.BaseIntegrationConfig."""
def setUp(self):
super(IntegrationConfigTests, self).setUp()
self.manager = IntegrationManager(IntegrationConfig)
self.integration = \
self.manager.register_integration_class(DummyIntegration1)
self.config = self.integration.create_config()
self.config.manager = self.manager
def test_integration(self):
"""Testing BaseIntegrationConfig.integration"""
self.assertEqual(self.config.integration, self.integration)
def test_get(self):
"""Testing BaseIntegrationConfig.get"""
self.config.settings['foo'] = 'bar'
self.assertEqual(self.config.get('foo'), 'bar')
def test_get_with_integration_defaults(self):
"""Testing BaseIntegrationConfig.get with integration defaults"""
self.assertEqual(self.config.get('foo'), 'default-foo')
def test_get_with_default(self):
"""Testing BaseIntegrationConfig.get with default"""
self.assertEqual(self.config.get('new-key', 'my-default'),
'my-default')
def test_set(self):
"""Testing BaseIntegrationConfig.set"""
self.config.set('my-key', 'my-value')
self.assertEqual(self.config.settings.get('my-key'), 'my-value')
示例9: test_register_integration_class
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_register_integration_class(self):
"""Testing IntegrationManager.register_integration_class"""
manager = IntegrationManager(IntegrationConfig)
integration = manager.register_integration_class(DummyIntegration1)
self.assertEqual(integration.__class__, DummyIntegration1)
integration_id = DummyIntegration1.integration_id
self.assertEqual(integration_id, "djblets.integrations.tests.test_manager.DummyIntegration1")
self.assertIn(integration_id, manager._integration_classes)
self.assertEqual(manager._integration_classes[integration_id], DummyIntegration1)
self.assertIn(integration_id, manager._integration_instances)
self.assertEqual(manager._integration_instances[integration_id], integration)
示例10: test_get_integration_configs_with_filter
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_get_integration_configs_with_filter(self):
"""Testing IntegrationManager.get_integration_configs with filter"""
manager = IntegrationManager(IntegrationConfig)
integration1 = manager.register_integration_class(DummyIntegration1)
integration2 = manager.register_integration_class(DummyIntegration2)
config1 = integration1.create_config(enabled=False, save=True)
integration1.create_config(enabled=True, save=True)
integration2.create_config(enabled=True, save=True)
with self.assertNumQueries(1):
configs = manager.get_integration_configs(integration1, enabled=False)
self.assertEqual(set(configs), {config1})
示例11: test_unregister_integration_class_with_enabled_integration
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_unregister_integration_class_with_enabled_integration(self):
"""Testing IntegrationManager.unregister_integration_class with
enabled integration
"""
manager = IntegrationManager(IntegrationConfig)
integration = manager.register_integration_class(DummyIntegration1)
integration_id = DummyIntegration1.integration_id
integration.enabled = True
manager.unregister_integration_class(DummyIntegration1)
self.assertFalse(integration.enabled)
self.assertNotIn(integration_id, manager._integration_classes)
self.assertNotIn(integration_id, manager._integration_instances)
示例12: test_get_integration_configs_caches
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_get_integration_configs_caches(self):
"""Testing IntegrationManager.get_integration_configs caches results"""
manager = IntegrationManager(IntegrationConfig)
integration1 = manager.register_integration_class(DummyIntegration1)
config1 = integration1.create_config(enabled=True, save=True)
config2 = integration1.create_config(enabled=False, save=True)
with self.assertNumQueries(1):
manager.get_integration_configs()
with self.assertNumQueries(0):
configs = manager.get_integration_configs()
self.assertEqual(set(configs), {config1, config2})
示例13: test_get_integration_configs
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_get_integration_configs(self):
"""Testing IntegrationManager.get_integration_configs with all
configurations
"""
manager = IntegrationManager(IntegrationConfig)
integration1 = manager.register_integration_class(DummyIntegration1)
integration2 = manager.register_integration_class(DummyIntegration2)
config1 = integration1.create_config(enabled=True, save=True)
config2 = integration1.create_config(enabled=False, save=True)
config3 = integration2.create_config(enabled=True, save=True)
with self.assertNumQueries(1):
configs = manager.get_integration_configs()
self.assertEqual(set(configs), {config1, config2, config3})
示例14: test_shutdown
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
def test_shutdown(self):
"""Testing IntegrationManager.shutdown"""
manager = IntegrationManager(IntegrationConfig)
instance = manager.register_integration_class(DummyIntegration1)
instance.enable_integration()
self.assertTrue(instance.enabled)
self.assertNotEqual(manager._integration_classes, {})
self.assertNotEqual(manager._integration_instances, {})
self.assertTrue(manager.is_expired())
manager.shutdown()
self.assertFalse(instance.enabled)
self.assertEqual(manager._integration_classes, {})
self.assertEqual(manager._integration_instances, {})
self.assertFalse(manager.is_expired())
示例15: IntegrationTests
# 需要导入模块: from djblets.integrations.manager import IntegrationManager [as 别名]
# 或者: from djblets.integrations.manager.IntegrationManager import register_integration_class [as 别名]
class IntegrationTests(IntegrationsTestCase):
"""Unit tests for djblets.integrations.integration.Integration."""
def setUp(self):
super(IntegrationTests, self).setUp()
self.manager = IntegrationManager(IntegrationConfig)
self.integration = \
self.manager.register_integration_class(DummyIntegration1)
def test_init(self):
"""Testing Integration initialization"""
self.assertEqual(self.integration.hooks, set())
self.assertFalse(self.integration.enabled)
self.assertFalse(hasattr(self.integration, 'dummy_initted'))
def test_id(self):
"""Testing Integration.id"""
self.assertEqual(self.integration.id, self.integration.integration_id)
def test_enable_integration(self):
"""Testing Integration.enable_integration"""
self.integration.enable_integration()
self.assertTrue(self.integration.enabled)
self.assertTrue(hasattr(self.integration, 'dummy_initted'))
self.assertTrue(self.integration.dummy_initted)
self.assertEqual(self.integration.hooks, {self.integration.hook})
def test_disable_integration(self):
"""Testing Integration.disable_integration"""
self.integration.enable_integration()
self.integration.disable_integration()
self.assertFalse(self.integration.enabled)
self.assertTrue(hasattr(self.integration, 'dummy_initted'))
self.assertFalse(self.integration.dummy_initted)
self.assertEqual(self.integration.hooks, set())
def test_get_configs(self):
"""Testing Integration.get_configs"""
config1 = self.integration.create_config(name='Config 1',
enabled=True,
save=True)
config2 = self.integration.create_config(name='Config 2',
enabled=True,
save=True)
# Add some configs that shouldn't be returned.
integration2 = \
self.manager.register_integration_class(DummyIntegration2)
self.integration.create_config(name='Config 3', save=True)
integration2.create_config(name='Config 4', save=True)
self.assertEqual(self.integration.get_configs(), [config1, config2])
def test_get_configs_with_filter(self):
"""Testing Integration.get_configs with filter"""
config1 = self.integration.create_config(name='Config 1',
enabled=True,
save=True)
self.integration.create_config(name='Config 2',
enabled=True,
save=True)
# Add some configs that shouldn't be returned.
integration2 = \
self.manager.register_integration_class(DummyIntegration2)
self.integration.create_config(name='Config 3', save=True)
integration2.create_config(name='Config 4', save=True)
self.assertEqual(self.integration.get_configs(name='Config 1'),
[config1])
def test_create_config(self):
"""Testing Integration.create_config"""
config = self.integration.create_config(name='Config 1')
self.assertFalse(config.enabled)
self.assertIsNone(config.pk)
def test_create_config_with_save(self):
"""Testing Integration.create_config with save=True"""
config = self.integration.create_config(name='Config 1', save=True)
self.assertFalse(config.enabled)
self.assertIsNotNone(config.pk)