Allow to register plugins with one POST call.

Partial-Bug: 1516766
Change-Id: Iac9725fcb1b3286c890f0180f5cf3bfc81262709
Depends-On: I44ca87663644797267647a3a08b970b6a6604bdc
This commit is contained in:
Vitalii Myhal
2016-02-23 14:56:29 -06:00
parent f657e8e034
commit d24e689cdc
2 changed files with 6 additions and 7 deletions

View File

@@ -279,7 +279,7 @@ class Plugins(base.BaseObject):
:param str name: plugin name
:param str version: plugin version
:param str force: if True updates meta information
:param bool force: if True updates meta information
about the plugin even it does not
support updates
"""
@@ -330,8 +330,10 @@ class Plugins(base.BaseObject):
def install(cls, plugin_path, force=False):
"""Installs the package, and creates data in API service
:param str name: plugin name
:param str version: plugin version
:param str plugin_path: Name of plugin file
:param bool force: Updates existent plugin even if it is not updatable
:return: Plugins information
:rtype: dict
"""
plugin = cls.make_obj_by_file(plugin_path)
@@ -340,7 +342,6 @@ class Plugins(base.BaseObject):
plugin.install(plugin_path, force=force)
response = cls.register(name, version, force=force)
cls.sync(plugin_ids=[response['id']])
return response

View File

@@ -220,10 +220,9 @@ class TestPluginsObject(base.UnitTestCase):
get_mock.assert_called_once_with(self.name, self.version)
del_mock.assert_called_once_with('plugins/123')
@patch.object(Plugins, 'sync')
@patch.object(Plugins, 'register')
@patch.object(Plugins, 'make_obj_by_file')
def test_install(self, make_obj_by_file_mock, register_mock, sync_mock):
def test_install(self, make_obj_by_file_mock, register_mock):
plugin_obj = self.mock_make_obj_by_file(make_obj_by_file_mock)
register_mock.return_value = {'id': 1}
self.plugin.install(self.path)
@@ -231,7 +230,6 @@ class TestPluginsObject(base.UnitTestCase):
plugin_obj.install.assert_called_once_with(self.path, force=False)
register_mock.assert_called_once_with(
'retrieved_name', 'retrieved_version', force=False)
sync_mock.assert_called_once_with(plugin_ids=[1])
@patch.object(Plugins, 'unregister')
@patch.object(Plugins, 'make_obj_by_name')