summaryrefslogtreecommitdiff
path: root/tests/unit/test_shell.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-07-10 18:54:30 +0000
committerGerrit Code Review <review@openstack.org>2019-07-10 18:54:30 +0000
commit2fcd4d872713dc30e7352845c37515280f1d21ab (patch)
tree76024c37110dfa755e8d0e752b1537c152aba3cf /tests/unit/test_shell.py
parent7cf8541b38a8782decdd27cb37909e737ed67b8a (diff)
parent936631eac617c83bec1f1c44b1adcaa51d36329c (diff)
downloadpython-swiftclient-2fcd4d872713dc30e7352845c37515280f1d21ab.tar.gz
Merge "Optionally display listings in raw json"
Diffstat (limited to 'tests/unit/test_shell.py')
-rw-r--r--tests/unit/test_shell.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py
index f729c25..d9ddb3e 100644
--- a/tests/unit/test_shell.py
+++ b/tests/unit/test_shell.py
@@ -298,6 +298,26 @@ class TestShell(unittest.TestCase):
headers={'Skip-Middleware': 'Test'})])
@mock.patch('swiftclient.service.Connection')
+ def test_list_json(self, connection):
+ connection.return_value.get_account.side_effect = [
+ [None, [{'name': 'container'}]],
+ [None, [{'name': u'\u263A', 'some-custom-key': 'and value'}]],
+ [None, []],
+ ]
+
+ argv = ["", "list", "--json"]
+ with CaptureOutput(suppress_systemexit=True) as output:
+ swiftclient.shell.main(argv)
+ calls = [mock.call(marker='', prefix=None, headers={}),
+ mock.call(marker='container', prefix=None, headers={})]
+ connection.return_value.get_account.assert_has_calls(calls)
+
+ listing = [{'name': 'container'},
+ {'name': u'\u263A', 'some-custom-key': 'and value'}]
+ expected = json.dumps(listing, sort_keys=True, indent=2) + '\n'
+ self.assertEqual(output.out, expected)
+
+ @mock.patch('swiftclient.service.Connection')
def test_list_account(self, connection):
# Test account listing
connection.return_value.get_account.side_effect = [