diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-08-06 00:10:32 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-08-06 00:10:32 +0000 |
commit | 92178ac17c9549fcf88d39c50ecadfd2979b9c44 (patch) | |
tree | cc9a5c5af59a35c0e89706f4a82d1502637dee40 /tests | |
parent | d460db84edb11cd57ed12b092a21224e870a4228 (diff) | |
parent | 335570e511e5c3a748969d921714a8b9e287e1ac (diff) | |
download | python-swiftclient-92178ac17c9549fcf88d39c50ecadfd2979b9c44.tar.gz |
Merge "Add --json option to `swift capabilities` / `swift info`"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_shell.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py index 59f0d5f..b786c77 100644 --- a/tests/unit/test_shell.py +++ b/tests/unit/test_shell.py @@ -16,6 +16,7 @@ from __future__ import unicode_literals from genericpath import getmtime import hashlib +import json import logging import mock import os @@ -1285,6 +1286,21 @@ class TestShell(unittest.TestCase): swiftclient.shell.main(argv) connection.return_value.get_capabilities.assert_called_with(None) + @mock.patch('swiftclient.service.Connection') + def test_capabilities_json(self, connection): + capabilities = { + 'slo': {'min_segment_size': 1000000}, + 'some': [{'arbitrary': 'nested'}, {'crazy': 'structure'}], + 'swift': {'version': '2.5.0'}} + + connection.return_value.get_capabilities.return_value = capabilities + argv = ["", "capabilities", "--json"] + with CaptureOutput(suppress_systemexit=True) as output: + swiftclient.shell.main(argv) + expected = json.dumps(capabilities, sort_keys=True, indent=2) + '\n' + self.assertEqual(expected, output.out) + connection.return_value.get_capabilities.assert_called_with(None) + def test_human_readable_upload_segment_size(self): def _check_expected(x, expected): actual = x.call_args_list[-1][1]["options"]["segment_size"] |