diff options
author | Andrey Pavlov <apavlov@mirantis.com> | 2015-10-27 15:52:05 +0300 |
---|---|---|
committer | Andrey Pavlov <apavlov@mirantis.com> | 2015-11-09 17:39:58 +0000 |
commit | ce767108694288fd6cd574f2a2796322e6ee8c09 (patch) | |
tree | 5fc88302cf3c6a9cdf7df3d9a96aaa294c718bd7 /saharaclient/tests | |
parent | 205b981d06ae96e5d957aa3dc4338536869e8d2e (diff) | |
download | python-saharaclient-ce767108694288fd6cd574f2a2796322e6ee8c09.tar.gz |
Images CLI improvement
* fixing representation after image is registered
* adding ability to register images by name
* adding additional ut
Partially implements: blueprint cli-as-openstackclient-plugin
Change-Id: Idda6aefa6406b49c8aa6c4de67d1de73878c5661
Diffstat (limited to 'saharaclient/tests')
-rw-r--r-- | saharaclient/tests/unit/osc/v1/test_images.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/saharaclient/tests/unit/osc/v1/test_images.py b/saharaclient/tests/unit/osc/v1/test_images.py index 8812d2c..e94a1d0 100644 --- a/saharaclient/tests/unit/osc/v1/test_images.py +++ b/saharaclient/tests/unit/osc/v1/test_images.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import mock + from openstackclient.tests import utils as osc_utils from saharaclient.api import images as api_images @@ -171,8 +173,11 @@ class TestShowImage(TestImages): class TestRegisterImage(TestImages): def setUp(self): super(TestRegisterImage, self).setUp() - self.image_mock.update_image.return_value = api_images.Image( - None, IMAGE_INFO) + self.image_mock.update_image.return_value = mock.Mock( + image=IMAGE_INFO.copy()) + self.app.client_manager.image = mock.Mock() + self.image_client = self.app.client_manager.image.images + self.image_client.get.return_value = mock.Mock(id='id') # Command to test self.cmd = osc_images.RegisterImage(self.app, None) @@ -184,7 +189,7 @@ class TestRegisterImage(TestImages): self.assertRaises(osc_utils.ParserException, self.check_parser, self.cmd, arglist, verifylist) - def test_image_register(self): + def test_image_register_required_options(self): arglist = ['id', '--username', 'ubuntu'] verifylist = [('image', 'id'), ('username', 'ubuntu')] @@ -194,7 +199,7 @@ class TestRegisterImage(TestImages): # Check that correct arguments were passed self.image_mock.update_image.assert_called_once_with( - 'id', desc='', user_name='ubuntu') + 'id', desc=None, user_name='ubuntu') # Check that columns are correct expected_columns = ('Description', 'Id', 'Name', 'Status', 'Tags', @@ -206,6 +211,19 @@ class TestRegisterImage(TestImages): '0.1, fake', 'ubuntu'] self.assertEqual(expected_data, list(data)) + def test_image_register_all_options(self): + arglist = ['id', '--username', 'ubuntu', '--description', 'descr'] + verifylist = [('image', 'id'), ('username', 'ubuntu'), + ('description', 'descr')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + # Check that correct arguments were passed + self.image_mock.update_image.assert_called_once_with( + 'id', desc='descr', user_name='ubuntu') + class TestUnregisterImage(TestImages): def setUp(self): |