summaryrefslogtreecommitdiff
path: root/glanceclient/tests/unit
diff options
context:
space:
mode:
authorMridula Joshi <mrjoshi@redhat.com>2022-01-12 13:28:07 +0000
committerMridula Joshi <mrjoshi@redhat.com>2022-02-02 14:31:44 +0000
commit282ce9c209d60ecb496e3e66126b71791fe6a1d4 (patch)
tree3448e169918c95601fe41f36b58d8f481b994fdb /glanceclient/tests/unit
parent5d714bed0b653b42b49b2c571b798a5e9b738539 (diff)
downloadpython-glanceclient-282ce9c209d60ecb496e3e66126b71791fe6a1d4.tar.gz
Add an optional parameter --detail
This patch appends th --detail parameter to the ``stores-info`` command. With sufficient permissions, display additional information about the stores. Depends-On: https://review.opendev.org/c/openstack/glance/+/824438 Change-Id: I6ae08ab3eaab0c2b118aa7607246214b28025dfe
Diffstat (limited to 'glanceclient/tests/unit')
-rw-r--r--glanceclient/tests/unit/v2/test_shell_v2.py52
1 files changed, 50 insertions, 2 deletions
diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py
index 83c4727..a96c70e 100644
--- a/glanceclient/tests/unit/v2/test_shell_v2.py
+++ b/glanceclient/tests/unit/v2/test_shell_v2.py
@@ -150,8 +150,44 @@ class ShellV2Test(testtools.TestCase):
]
}
+ stores_info_detail_response = {
+ "stores": [
+ {
+ "default": "true",
+ "id": "ceph1",
+ "type": "rbd",
+ "description": "RBD backend for glance.",
+ "properties": {
+ "pool": "pool1",
+ "chunk_size": "4"
+ }
+ },
+ {
+ "id": "file2",
+ "type": "file",
+ "description": "Filesystem backend for glance.",
+ "properties": {}
+ },
+ {
+ "id": "file1",
+ "type": "file",
+ "description": "Filesystem backend for gkance.",
+ "properties": {}
+ },
+ {
+ "id": "ceph2",
+ "type": "rbd",
+ "description": "RBD backend for glance.",
+ "properties": {
+ "pool": "pool2",
+ "chunk_size": "4"
+ }
+ }
+ ]
+ }
+
def test_do_stores_info(self):
- args = []
+ args = self._make_args({'detail': False})
with mock.patch.object(self.gc.images,
'get_stores_info') as mocked_list:
mocked_list.return_value = self.stores_info_response
@@ -166,7 +202,7 @@ class ShellV2Test(testtools.TestCase):
def test_neg_stores_info(
self, mock_stdin, mock_utils_exit):
expected_msg = ('Multi Backend support is not enabled')
- args = []
+ args = self._make_args({'detail': False})
mock_utils_exit.side_effect = self._mock_utils_exit
with mock.patch.object(self.gc.images,
'get_stores_info') as mocked_info:
@@ -178,6 +214,18 @@ class ShellV2Test(testtools.TestCase):
pass
mock_utils_exit.assert_called_once_with(expected_msg)
+ def test_do_stores_info_with_detail(self):
+ args = self._make_args({'detail': True})
+ with mock.patch.object(self.gc.images,
+ 'get_stores_info_detail') as mocked_list:
+ mocked_list.return_value = self.stores_info_detail_response
+
+ test_shell.do_stores_info(self.gc, args)
+
+ mocked_list.assert_called_once_with()
+ utils.print_dict.assert_called_once_with(
+ self.stores_info_detail_response)
+
@mock.patch('sys.stderr')
def test_image_create_missing_disk_format(self, __):
e = self.assertRaises(exc.CommandError, self._run_command,