summaryrefslogtreecommitdiff
path: root/tests/unit/test_shell.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/test_shell.py')
-rw-r--r--tests/unit/test_shell.py16
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"]