diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-12-30 13:22:07 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2017-01-03 23:30:49 +0800 |
| commit | 96578cb8ab9a4b95144c33d0af38863fce8d8892 (patch) | |
| tree | 8fd9c537b48aae84b9b3eaac8aa17079adf251b0 /openstackclient/tests/unit/identity/v3/test_group.py | |
| parent | f020a9ffd6d5602d18c899e7707baaa620ffdd54 (diff) | |
| download | python-openstackclient-96578cb8ab9a4b95144c33d0af38863fce8d8892.tar.gz | |
Error handling for delete commands in identity
Add missing multi deletion error handling for
identity delete commands.
All delete commands in identity support
error handling now.
Change-Id: I05626dcb5e516a423d610906347b02236ba7eeaf
Diffstat (limited to 'openstackclient/tests/unit/identity/v3/test_group.py')
| -rw-r--r-- | openstackclient/tests/unit/identity/v3/test_group.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/identity/v3/test_group.py b/openstackclient/tests/unit/identity/v3/test_group.py index eb50adb5..8558de95 100644 --- a/openstackclient/tests/unit/identity/v3/test_group.py +++ b/openstackclient/tests/unit/identity/v3/test_group.py @@ -16,6 +16,7 @@ from mock import call from keystoneauth1 import exceptions as ks_exc from osc_lib import exceptions +from osc_lib import utils from openstackclient.identity.v3 import group from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes @@ -257,6 +258,32 @@ class TestGroupDelete(TestGroup): self.groups_mock.delete.assert_called_once_with(self.groups[0].id) self.assertIsNone(result) + @mock.patch.object(utils, 'find_resource') + def test_delete_multi_groups_with_exception(self, find_mock): + find_mock.side_effect = [self.groups[0], + exceptions.CommandError] + arglist = [ + self.groups[0].id, + 'unexist_group', + ] + verifylist = [ + ('groups', arglist), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + try: + self.cmd.take_action(parsed_args) + self.fail('CommandError should be raised.') + except exceptions.CommandError as e: + self.assertEqual('1 of 2 groups failed to delete.', + str(e)) + + find_mock.assert_any_call(self.groups_mock, self.groups[0].id) + find_mock.assert_any_call(self.groups_mock, 'unexist_group') + + self.assertEqual(2, find_mock.call_count) + self.groups_mock.delete.assert_called_once_with(self.groups[0].id) + class TestGroupList(TestGroup): |
