Merge "Add commands from extensions to available commands"

This commit is contained in:
Jenkins
2015-03-18 21:32:11 +00:00
committed by Gerrit Code Review
2 changed files with 12 additions and 2 deletions

View File

@@ -696,6 +696,7 @@ class NeutronShell(app.App):
continue
try:
self.command_manager.add_command(cmd, cls)
self.commands[version][cmd] = cls
except TypeError:
pass

View File

@@ -19,6 +19,7 @@ import sys
import mock
from neutronclient.neutron.v2_0.contrib import _fox_sockets as fox_sockets
from neutronclient import shell
from neutronclient.tests.unit import test_cli20
@@ -37,10 +38,18 @@ class CLITestV20ExtensionJSON(test_cli20.CLITestV20Base):
def _mock_extension_loading(self):
ext_pkg = 'neutronclient.common.extension'
contrib = self._create_patch(ext_pkg + '._discover_via_entry_points')
iterator = iter([("_fox_sockets", fox_sockets)])
contrib.return_value.__iter__.return_value = iterator
contrib.return_value = [("_fox_sockets", fox_sockets)]
return contrib
def test_ext_cmd_loaded(self):
shell.NeutronShell('2.0')
ext_cmd = {'fox-sockets-list': fox_sockets.FoxInSocketsList,
'fox-sockets-create': fox_sockets.FoxInSocketsCreate,
'fox-sockets-update': fox_sockets.FoxInSocketsUpdate,
'fox-sockets-delete': fox_sockets.FoxInSocketsDelete,
'fox-sockets-show': fox_sockets.FoxInSocketsShow}
self.assertDictContainsSubset(ext_cmd, shell.COMMANDS['2.0'])
def test_delete_fox_socket(self):
"""Delete fox socket: myid."""
resource = 'fox_socket'