diff options
| author | sunyajing <yajing.sun@easystack.cn> | 2016-06-14 15:44:41 +0800 |
|---|---|---|
| committer | Steve Martinelli <s.martinelli@gmail.com> | 2016-06-17 04:20:28 +0000 |
| commit | 8a12a39ece3882af56b42898ffee0d537c96edc8 (patch) | |
| tree | 035553e001193a212fb55d51877585371cd3d16e /openstackclient/tests | |
| parent | 2c92b60f457a16c315b6286592e9fee534bd4b3d (diff) | |
| download | python-openstackclient-8a12a39ece3882af56b42898ffee0d537c96edc8.tar.gz | |
Make set/unset command in identity and image pass normally when nothing specified
Also update its unit tests.
Change-Id: I82b90658b0d4247cdc9a650f14aceda640a32059
Partial-bug: #1588588
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/identity/v2_0/test_project.py | 34 | ||||
| -rw-r--r-- | openstackclient/tests/identity/v2_0/test_user.py | 22 | ||||
| -rw-r--r-- | openstackclient/tests/image/v2/test_image.py | 26 |
3 files changed, 82 insertions, 0 deletions
diff --git a/openstackclient/tests/identity/v2_0/test_project.py b/openstackclient/tests/identity/v2_0/test_project.py index 38684aaf..1eb12604 100644 --- a/openstackclient/tests/identity/v2_0/test_project.py +++ b/openstackclient/tests/identity/v2_0/test_project.py @@ -16,6 +16,7 @@ import copy from keystoneauth1 import exceptions as ks_exc +from osc_lib import exceptions from openstackclient.identity.v2_0 import project from openstackclient.tests import fakes @@ -410,6 +411,26 @@ class TestProjectSet(TestProject): self.assertIsNone(result) + def test_project_set_unexist_project(self): + arglist = [ + "unexist-project", + ] + verifylist = [ + ('project', "unexist-project"), + ('name', None), + ('description', None), + ('enable', False), + ('disable', False), + ('property', None), + ] + self.projects_mock.get.side_effect = exceptions.NotFound(None) + self.projects_mock.find.side_effect = exceptions.NotFound(None) + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.assertRaises( + exceptions.CommandError, self.cmd.take_action, parsed_args) + def test_project_set_name(self): arglist = [ '--name', 'qwerty', @@ -604,6 +625,19 @@ class TestProjectUnset(TestProject): # Get the command object to test self.cmd = project.UnsetProject(self.app, None) + def test_project_unset_no_options(self): + arglist = [ + identity_fakes.project_name, + ] + verifylist = [ + ('project', identity_fakes.project_name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + + self.assertIsNone(result) + def test_project_unset_key(self): arglist = [ '--property', 'fee', diff --git a/openstackclient/tests/identity/v2_0/test_user.py b/openstackclient/tests/identity/v2_0/test_user.py index caf38a6f..f7a7b08c 100644 --- a/openstackclient/tests/identity/v2_0/test_user.py +++ b/openstackclient/tests/identity/v2_0/test_user.py @@ -17,6 +17,7 @@ import copy import mock from keystoneauth1 import exceptions as ks_exc +from osc_lib import exceptions from openstackclient.identity.v2_0 import user from openstackclient.tests import fakes @@ -563,6 +564,27 @@ class TestUserSet(TestUser): self.assertIsNone(result) + def test_user_set_unexist_user(self): + arglist = [ + "unexist-user", + ] + verifylist = [ + ('name', None), + ('password', None), + ('email', None), + ('project', None), + ('enable', False), + ('disable', False), + ('user', "unexist-user"), + ] + self.users_mock.get.side_effect = exceptions.NotFound(None) + self.users_mock.find.side_effect = exceptions.NotFound(None) + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.assertRaises( + exceptions.CommandError, self.cmd.take_action, parsed_args) + def test_user_set_name(self): arglist = [ '--name', 'qwerty', diff --git a/openstackclient/tests/image/v2/test_image.py b/openstackclient/tests/image/v2/test_image.py index 92e0660f..3dbf504a 100644 --- a/openstackclient/tests/image/v2/test_image.py +++ b/openstackclient/tests/image/v2/test_image.py @@ -811,6 +811,19 @@ class TestImageSet(TestImage): # Get the command object to test self.cmd = image.SetImage(self.app, None) + def test_image_set_no_options(self): + arglist = [ + image_fakes.image_id, + ] + verifylist = [ + ('image', image_fakes.image_id) + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + + self.assertIsNone(result) + def test_image_set_options(self): arglist = [ '--name', 'new-name', @@ -1211,6 +1224,19 @@ class TestImageUnset(TestImage): # Get the command object to test self.cmd = image.UnsetImage(self.app, None) + def test_image_unset_no_options(self): + arglist = [ + image_fakes.image_id, + ] + verifylist = [ + ('image', image_fakes.image_id) + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + + self.assertIsNone(result) + def test_image_unset_tag_option(self): arglist = [ |
