summaryrefslogtreecommitdiff
path: root/cinderclient/tests
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-01-26 18:13:28 +0000
committerGerrit Code Review <review@openstack.org>2023-01-26 18:13:28 +0000
commit6579899d3aedfaf041850c10904c9e4769809c20 (patch)
tree7c1de6d2cf951660f97500e19a5b016e093e957d /cinderclient/tests
parentc66b9911b8dcf89910fcab45e9a8211e30419ccf (diff)
parent2d7ae2cd38a2194f98b71d4d98c4273e9ad33e72 (diff)
downloadpython-cinderclient-6579899d3aedfaf041850c10904c9e4769809c20.tar.gz
Merge "Move print operations to shell_utils"
Diffstat (limited to 'cinderclient/tests')
-rw-r--r--cinderclient/tests/unit/test_shell.py2
-rw-r--r--cinderclient/tests/unit/test_utils.py18
-rw-r--r--cinderclient/tests/unit/v3/test_shell.py12
3 files changed, 16 insertions, 16 deletions
diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py
index 4808689..c5d64af 100644
--- a/cinderclient/tests/unit/test_shell.py
+++ b/cinderclient/tests/unit/test_shell.py
@@ -554,7 +554,7 @@ class TestLoadVersionedActions(utils.TestCase):
class ShellUtilsTest(utils.TestCase):
- @mock.patch.object(cinderclient.utils, 'print_dict')
+ @mock.patch.object(cinderclient.shell_utils, 'print_dict')
def test_print_volume_image(self, mock_print_dict):
response = {'os-volume_upload_image': {'name': 'myimg1'}}
image_resp_tuple = (202, response)
diff --git a/cinderclient/tests/unit/test_utils.py b/cinderclient/tests/unit/test_utils.py
index cce4498..69b0d04 100644
--- a/cinderclient/tests/unit/test_utils.py
+++ b/cinderclient/tests/unit/test_utils.py
@@ -220,7 +220,7 @@ class PrintListTestCase(test_utils.TestCase):
Row = collections.namedtuple('Row', ['a', 'b'])
to_print = [Row(a=3, b=4), Row(a=1, b=2)]
with CaptureStdout() as cso:
- utils.print_list(to_print, ['a', 'b'])
+ shell_utils.print_list(to_print, ['a', 'b'])
# Output should be sorted by the first key (a)
self.assertEqual("""\
+---+---+
@@ -235,7 +235,7 @@ class PrintListTestCase(test_utils.TestCase):
Row = collections.namedtuple('Row', ['a', 'b'])
to_print = [Row(a=3, b=None), Row(a=1, b=2)]
with CaptureStdout() as cso:
- utils.print_list(to_print, ['a', 'b'])
+ shell_utils.print_list(to_print, ['a', 'b'])
# Output should be sorted by the first key (a)
self.assertEqual("""\
+---+---+
@@ -250,7 +250,7 @@ class PrintListTestCase(test_utils.TestCase):
Row = collections.namedtuple('Row', ['a', 'b'])
to_print = [Row(a=4, b=3), Row(a=2, b=1)]
with CaptureStdout() as cso:
- utils.print_list(to_print, ['a', 'b'], sortby_index=1)
+ shell_utils.print_list(to_print, ['a', 'b'], sortby_index=1)
# Output should be sorted by the second key (b)
self.assertEqual("""\
+---+---+
@@ -265,7 +265,7 @@ class PrintListTestCase(test_utils.TestCase):
Row = collections.namedtuple('Row', ['a', 'b'])
to_print = [Row(a=3, b=4), Row(a=1, b=2)]
with CaptureStdout() as cso:
- utils.print_list(to_print, ['a', 'b'], sortby_index=None)
+ shell_utils.print_list(to_print, ['a', 'b'], sortby_index=None)
# Output should be in the order given
self.assertEqual("""\
+---+---+
@@ -283,7 +283,7 @@ class PrintListTestCase(test_utils.TestCase):
for row in [Row(a=1, b=2), Row(a=3, b=4)]:
yield row
with CaptureStdout() as cso:
- utils.print_list(gen_rows(), ['a', 'b'])
+ shell_utils.print_list(gen_rows(), ['a', 'b'])
self.assertEqual("""\
+---+---+
| a | b |
@@ -297,7 +297,7 @@ class PrintListTestCase(test_utils.TestCase):
Row = collections.namedtuple('Row', ['a', 'b'])
to_print = [Row(a=3, b='a\r'), Row(a=1, b='c\rd')]
with CaptureStdout() as cso:
- utils.print_list(to_print, ['a', 'b'])
+ shell_utils.print_list(to_print, ['a', 'b'])
# Output should be sorted by the first key (a)
self.assertEqual("""\
+---+-----+
@@ -314,13 +314,13 @@ class PrintDictTestCase(test_utils.TestCase):
def test__pretty_format_dict(self):
content = {'key1': 'value1', 'key2': 'value2'}
expected = "key1 : value1\nkey2 : value2"
- result = utils._pretty_format_dict(content)
+ result = shell_utils._pretty_format_dict(content)
self.assertEqual(expected, result)
def test_print_dict_with_return(self):
d = {'a': 'A', 'b': 'B', 'c': 'C', 'd': 'test\rcarriage\n\rreturn'}
with CaptureStdout() as cso:
- utils.print_dict(d)
+ shell_utils.print_dict(d)
self.assertEqual("""\
+----------+---------------+
| Property | Value |
@@ -337,7 +337,7 @@ class PrintDictTestCase(test_utils.TestCase):
content = {'a': 'A', 'b': 'B', 'f_key':
{'key1': 'value1', 'key2': 'value2'}}
with CaptureStdout() as cso:
- utils.print_dict(content, formatters='f_key')
+ shell_utils.print_dict(content, formatters='f_key')
self.assertEqual("""\
+----------+---------------+
| Property | Value |
diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py
index 7c5f110..58caddc 100644
--- a/cinderclient/tests/unit/v3/test_shell.py
+++ b/cinderclient/tests/unit/v3/test_shell.py
@@ -352,7 +352,7 @@ class ShellTest(utils.TestCase):
self.run_command(command)
self.assert_called('GET', '/volumes/detail?group_id=fake_id')
- @mock.patch("cinderclient.utils.print_list")
+ @mock.patch("cinderclient.shell_utils.print_list")
def test_list_duplicate_fields(self, mock_print):
self.run_command('list --field Status,id,Size,status')
self.assert_called('GET', '/volumes/detail')
@@ -528,7 +528,7 @@ class ShellTest(utils.TestCase):
self.run_command(command)
self.assert_called('GET', '/attachments%s' % expected)
- @mock.patch('cinderclient.utils.print_list')
+ @mock.patch('cinderclient.shell_utils.print_list')
@mock.patch.object(cinderclient.v3.attachments.VolumeAttachmentManager,
'list')
def test_attachment_list_setattr(self, mock_list, mock_print):
@@ -1285,7 +1285,7 @@ class ShellTest(utils.TestCase):
get_levels_mock.assert_not_called()
@mock.patch('cinderclient.v3.services.ServiceManager.get_log_levels')
- @mock.patch('cinderclient.utils.print_list')
+ @mock.patch('cinderclient.shell_utils.print_list')
def test_service_get_log_no_params(self, print_mock, get_levels_mock):
self.run_command('--os-volume-api-version 3.32 service-get-log')
get_levels_mock.assert_called_once_with('', '', '')
@@ -1296,7 +1296,7 @@ class ShellTest(utils.TestCase):
@ddt.data('*', 'cinder-api', 'cinder-volume', 'cinder-scheduler',
'cinder-backup')
@mock.patch('cinderclient.v3.services.ServiceManager.get_log_levels')
- @mock.patch('cinderclient.utils.print_list')
+ @mock.patch('cinderclient.shell_utils.print_list')
def test_service_get_log(self, binary, print_mock, get_levels_mock):
server = 'host1'
prefix = 'sqlalchemy'
@@ -1454,7 +1454,7 @@ class ShellTest(utils.TestCase):
'availability_zone': 'AZ2'}}
self.assert_called('POST', '/backups', body=expected)
- @mock.patch("cinderclient.utils.print_list")
+ @mock.patch("cinderclient.shell_utils.print_list")
def test_snapshot_list(self, mock_print_list):
"""Ensure we always present all existing fields when listing snaps."""
self.run_command('--os-volume-api-version 3.65 snapshot-list')
@@ -1923,7 +1923,7 @@ class ShellTest(utils.TestCase):
},
)
@ddt.unpack
- @mock.patch('cinderclient.utils.print_dict')
+ @mock.patch('cinderclient.shell_utils.print_dict')
@mock.patch('cinderclient.tests.unit.v3.fakes_base._stub_restore')
def test_do_backup_restore(self,
mock_stub_restore,