diff options
| author | Jordan Pittier <jordan.pittier@scality.com> | 2016-11-10 16:19:01 +0100 |
|---|---|---|
| committer | Jordan Pittier <jordan.pittier@scality.com> | 2016-11-10 16:30:23 +0100 |
| commit | 52279b1b04924284576966eb33192dd1301683bb (patch) | |
| tree | 0092fbb6679104b9641574ea5c90895983fa3060 /openstackclient/tests/unit/network/test_common.py | |
| parent | b37ad9992b69c16644222e8f092cd4bdc5e8292a (diff) | |
| download | python-openstackclient-52279b1b04924284576966eb33192dd1301683bb.tar.gz | |
network.common.NetworkAndComputeShowOne: catch HttpException
Problem: if a user issue the cmd 'openstack floating ip create public'
and has already maxed his quota for FIP, OSC exits with a not so useful
message:
>jordan@jordan-XPS13-9333:~ $ openstack floating ip create public
>HttpException: Conflict
This patches catch the HttpException earlier and prints a more
verbose message:
> jordan@jordan-XPS13-9333:~ $ openstack floating ip create public
> Error while executing command: Quota exceeded for resources: ['floatingip']
Change-Id: I7c87524d871d230d92f007c32e06439b34c7194a
Diffstat (limited to 'openstackclient/tests/unit/network/test_common.py')
| -rw-r--r-- | openstackclient/tests/unit/network/test_common.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/network/test_common.py b/openstackclient/tests/unit/network/test_common.py index 325aad2a..4b9a754b 100644 --- a/openstackclient/tests/unit/network/test_common.py +++ b/openstackclient/tests/unit/network/test_common.py @@ -14,6 +14,8 @@ import argparse import mock +import openstack +from openstackclient.common import exceptions from openstackclient.network import common from openstackclient.tests.unit import utils @@ -172,3 +174,15 @@ class TestNetworkAndComputeShowOne(TestNetworkAndCompute): def setUp(self): super(TestNetworkAndComputeShowOne, self).setUp() self.cmd = FakeNetworkAndComputeShowOne(self.app, self.namespace) + + def test_take_action_with_http_exception(self): + with mock.patch.object(self.cmd, 'take_action_network') as m_action: + m_action.side_effect = openstack.exceptions.HttpException("bar") + self.assertRaisesRegex(exceptions.CommandError, "bar", + self.cmd.take_action, mock.Mock()) + + self.app.client_manager.network_endpoint_enabled = False + with mock.patch.object(self.cmd, 'take_action_compute') as m_action: + m_action.side_effect = openstack.exceptions.HttpException("bar") + self.assertRaisesRegex(exceptions.CommandError, "bar", + self.cmd.take_action, mock.Mock()) |
