From 6f2c1734e3d66e261f231711455821321c1fc254 Mon Sep 17 00:00:00 2001 From: Richard Theis Date: Thu, 2 Jun 2016 09:53:55 -0500 Subject: Fix --enable options on commands The --enable option on commands is ignored when the arguments are parsed. This is related to the --enable-beta-commands option. Renaming the option to --os-beta-command fixes the problem. There's no need to handle backwards compatibility for the option name change because there hasn't been an OSC release yet with beta commands. Change-Id: I0327ba8a2058858a83e9a42e231470ed733cc834 Closes-Bug: #1588384 --- openstackclient/tests/common/test_command.py | 15 +++++++++++++++ openstackclient/tests/fakes.py | 2 +- openstackclient/tests/network/v2/test_network_segment.py | 6 +++--- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'openstackclient/tests') diff --git a/openstackclient/tests/common/test_command.py b/openstackclient/tests/common/test_command.py index 7467d9eb..722a4c06 100644 --- a/openstackclient/tests/common/test_command.py +++ b/openstackclient/tests/common/test_command.py @@ -15,6 +15,8 @@ import mock from openstackclient.common import command +from openstackclient.common import exceptions +from openstackclient.tests import fakes as test_fakes from openstackclient.tests import utils as test_utils @@ -31,3 +33,16 @@ class TestCommand(test_utils.TestCase): self.assertTrue(hasattr(cmd, 'log')) self.assertEqual('openstackclient.tests.common.test_command.' 'FakeCommand', cmd.log.name) + + def test_validate_os_beta_command_enabled(self): + cmd = FakeCommand(mock.Mock(), mock.Mock()) + cmd.app = mock.Mock() + cmd.app.options = test_fakes.FakeOptions() + + # No exception is raised when enabled. + cmd.app.options.os_beta_command = True + cmd.validate_os_beta_command_enabled() + + cmd.app.options.os_beta_command = False + self.assertRaises(exceptions.CommandError, + cmd.validate_os_beta_command_enabled) diff --git a/openstackclient/tests/fakes.py b/openstackclient/tests/fakes.py index 7fb1daa9..ad4705a4 100644 --- a/openstackclient/tests/fakes.py +++ b/openstackclient/tests/fakes.py @@ -99,7 +99,7 @@ class FakeApp(object): class FakeOptions(object): def __init__(self, **kwargs): - self.enable_beta_commands = False + self.os_beta_command = False class FakeClient(object): diff --git a/openstackclient/tests/network/v2/test_network_segment.py b/openstackclient/tests/network/v2/test_network_segment.py index 2822581c..0a99eced 100644 --- a/openstackclient/tests/network/v2/test_network_segment.py +++ b/openstackclient/tests/network/v2/test_network_segment.py @@ -25,7 +25,7 @@ class TestNetworkSegment(network_fakes.TestNetworkV2): super(TestNetworkSegment, self).setUp() # Enable beta commands. - self.app.options.enable_beta_commands = True + self.app.options.os_beta_command = True # Get a shortcut to the network client self.network = self.app.client_manager.network @@ -89,7 +89,7 @@ class TestListNetworkSegment(TestNetworkSegment): self.assertEqual(self.data, list(data)) def test_list_no_beta_commands(self): - self.app.options.enable_beta_commands = False + self.app.options.os_beta_command = False parsed_args = self.check_parser(self.cmd, [], []) self.assertRaises(exceptions.CommandError, self.cmd.take_action, parsed_args) @@ -174,7 +174,7 @@ class TestShowNetworkSegment(TestNetworkSegment): verifylist = [ ('network_segment', self._network_segment.id), ] - self.app.options.enable_beta_commands = False + self.app.options.os_beta_command = False parsed_args = self.check_parser(self.cmd, arglist, verifylist) self.assertRaises(exceptions.CommandError, self.cmd.take_action, parsed_args) -- cgit v1.2.1