From cfd4e2a7228c1e7f6ad677f2dd6dbd09e638dfb7 Mon Sep 17 00:00:00 2001 From: Huanxuan Ao Date: Thu, 9 Feb 2017 18:05:32 +0800 Subject: Modify error handling for role and group commands if command failed, we usually raise exception, if command success, sometimes there is not any output (such as set, add commands) So modify the error handling for role and group commands. Change-Id: I1c0f86c04dcedd9c0d725fd73f3436be9da75ee0 --- .../tests/unit/identity/v3/test_group.py | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'openstackclient/tests/unit/identity/v3/test_group.py') diff --git a/openstackclient/tests/unit/identity/v3/test_group.py b/openstackclient/tests/unit/identity/v3/test_group.py index 8558de95..00bd217d 100644 --- a/openstackclient/tests/unit/identity/v3/test_group.py +++ b/openstackclient/tests/unit/identity/v3/test_group.py @@ -70,6 +70,20 @@ class TestGroupAddUser(TestGroup): self.user.id, self.group.id) self.assertIsNone(result) + def test_group_add_user_with_error(self): + self.users_mock.add_to_group.side_effect = exceptions.CommandError() + arglist = [ + self.group.name, + self.user.name, + ] + verifylist = [ + ('group', self.group.name), + ('user', self.user.name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + self.assertRaises(exceptions.CommandError, + self.cmd.take_action, parsed_args) + class TestGroupCheckUser(TestGroup): @@ -460,6 +474,21 @@ class TestGroupRemoveUser(TestGroup): self.user.id, self.group.id) self.assertIsNone(result) + def test_group_remove_user_with_error(self): + self.users_mock.remove_from_group.side_effect = ( + exceptions.CommandError()) + arglist = [ + self.group.id, + self.user.id, + ] + verifylist = [ + ('group', self.group.id), + ('user', self.user.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + self.assertRaises(exceptions.CommandError, + self.cmd.take_action, parsed_args) + class TestGroupSet(TestGroup): -- cgit v1.2.1