summaryrefslogtreecommitdiff
path: root/cinderclient/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-08-16 06:40:50 +0000
committerGerrit Code Review <review@openstack.org>2015-08-16 06:40:50 +0000
commitac684902600a134c9f5dc3e36e3e5ab9dca97616 (patch)
treee12f1b108eedac152ef28e09373eff7fd3943c3e /cinderclient/tests
parentaf1f153b65558966b18e2fe1341091a3ee10f0d2 (diff)
parent2ec9a2251d1faa8a167e975bccbaa2e59137e47d (diff)
downloadpython-cinderclient-ac684902600a134c9f5dc3e36e3e5ab9dca97616.tar.gz
Merge "Fixes table when there are multiline in result data"
Diffstat (limited to 'cinderclient/tests')
-rw-r--r--cinderclient/tests/unit/test_utils.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/cinderclient/tests/unit/test_utils.py b/cinderclient/tests/unit/test_utils.py
index 73a39b9..2d2ebd1 100644
--- a/cinderclient/tests/unit/test_utils.py
+++ b/cinderclient/tests/unit/test_utils.py
@@ -204,3 +204,37 @@ class PrintListTestCase(test_utils.TestCase):
| 3 | 4 |
+---+---+
""", cso.read())
+
+ def test_print_list_with_return(self):
+ 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'])
+ # Output should be sorted by the first key (a)
+ self.assertEqual("""\
++---+-----+
+| a | b |
++---+-----+
+| 1 | c d |
+| 3 | a |
++---+-----+
+""", cso.read())
+
+
+class PrintDictTestCase(test_utils.TestCase):
+
+ 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)
+ self.assertEqual("""\
++----------+---------------+
+| Property | Value |
++----------+---------------+
+| a | A |
+| b | B |
+| c | C |
+| d | test carriage |
+| | return |
++----------+---------------+
+""", cso.read())