def test_unsupported_extensions_are_not_loaded(self): stub_plugin = StubPlugin(supported_extensions=["e1", "e3"]) ext_mgr = PluginAwareExtensionManager('', stub_plugin) ext_mgr.add_extension(StubExtension("e1")) ext_mgr.add_extension(StubExtension("e2")) ext_mgr.add_extension(StubExtension("e3")) self.assertTrue("e1" in ext_mgr.extensions) self.assertFalse("e2" in ext_mgr.extensions) self.assertTrue("e3" in ext_mgr.extensions)
def test_extensions_are_not_loaded_for_plugins_unaware_of_extensions(self): class ExtensionUnawarePlugin(object): """ This plugin does not implement supports_extension method. Extensions will not be loaded when this plugin is used. """ pass ext_mgr = PluginAwareExtensionManager('', ExtensionUnawarePlugin()) ext_mgr.add_extension(StubExtension("e1")) self.assertFalse("e1" in ext_mgr.extensions)
def test_invalid_extensions_are_not_registered(self): class InvalidExtension(object): """ This Extension doesn't implement extension methods : get_name, get_description, get_namespace and get_updated """ def get_alias(self): return "invalid_extension" ext_mgr = ExtensionManager('') ext_mgr.add_extension(InvalidExtension()) ext_mgr.add_extension(StubExtension("valid_extension")) self.assertTrue('valid_extension' in ext_mgr.extensions) self.assertFalse('invalid_extension' in ext_mgr.extensions)