summaryrefslogtreecommitdiff
path: root/cinderclient/tests/unit/test_utils.py
diff options
context:
space:
mode:
authorEric Harney <eharney@redhat.com>2022-11-09 12:28:38 -0500
committerEric Harney <eharney@redhat.com>2022-11-15 10:12:41 -0500
commit2d7ae2cd38a2194f98b71d4d98c4273e9ad33e72 (patch)
tree5edde3e30e7ca17a16f2270f3cf0728e085b4366 /cinderclient/tests/unit/test_utils.py
parent6f67187b8255ae231f82a9deaaf9156c868153a0 (diff)
downloadpython-cinderclient-2d7ae2cd38a2194f98b71d4d98c4273e9ad33e72.tar.gz
Move print operations to shell_utils
Move more code to shell_utils that is only used for shell operations. The benefit of this is that the cinderclient library becomes lighter-weight, because users of the lib no longer have to import prettytable and extra code. Change-Id: I7bf6bd91ee5746d1ad4bd4504f3a056d03ae86a9
Diffstat (limited to 'cinderclient/tests/unit/test_utils.py')
-rw-r--r--cinderclient/tests/unit/test_utils.py18
1 files changed, 9 insertions, 9 deletions
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 |