本文整理汇总了Python中djblets.integrations.manager.IntegrationManager类的典型用法代码示例。如果您正苦于以下问题:Python IntegrationManager类的具体用法?Python IntegrationManager怎么用?Python IntegrationManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IntegrationManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_check_expired_when_expired
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_is_expired_after_config_deleted
def test_is_expired_after_config_deleted(self):
"""Testing IntegrationManager.is_expired after config deleted"""
manager = IntegrationManager(IntegrationConfig)
self.assertFalse(manager.is_expired())
post_delete.send(sender=IntegrationConfig)
self.assertTrue(manager.is_expired())
示例3: test_unregister_integration_class_with_unregistered
def test_unregister_integration_class_with_unregistered(self):
"""Testing IntegrationManager.unregister_integration_class with
unregistered integration
"""
manager = IntegrationManager(IntegrationConfig)
with self.assertRaises(IntegrationNotRegisteredError):
manager.unregister_integration_class(DummyIntegration1)
示例4: test_get_integration_classes
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})
示例5: test_register_integration_class_with_construct_error
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)
示例6: test_register_integration_class_with_already_registered
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)
示例7: test_unregister_integration_class
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)
示例8: test_check_expired_when_not_expired
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, {})
示例9: test_is_expired_after_other_process_updates
def test_is_expired_after_other_process_updates(self):
"""Testing IntegrationManager.is_expired after another process updates
the configuration state
"""
manager = IntegrationManager(IntegrationConfig)
self.assertFalse(manager.is_expired())
gen_sync = GenerationSynchronizer(manager._gen_sync.cache_key, normalize_cache_key=False)
gen_sync.mark_updated()
self.assertTrue(manager.is_expired())
示例10: test_get_integration
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)
示例11: test_register_integration_class
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)
示例12: test_get_integration_configs_with_filter
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})
示例13: test_unregister_integration_class_with_enabled_integration
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)
示例14: test_get_integration_configs_caches
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})
示例15: test_get_integration_configs
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})