summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schwede <christian.schwede@enovance.com>2014-10-01 16:11:55 +0000
committerChristian Schwede <christian.schwede@enovance.com>2014-10-01 16:11:55 +0000
commitc37cecb6169a0e46aeebea64639a2cb8eb5afde1 (patch)
tree98ea8a130eed4bcdc73a00f5a352bb2b4f52774f
parent21fb6f6798015f9f3b9744cf660bdf01822f4b54 (diff)
downloadpython-swiftclient-c37cecb6169a0e46aeebea64639a2cb8eb5afde1.tar.gz
Add tests for account listing using --lh switch
Change-Id: I2e68a24212eda463f39a5d0be13f1645ca2a23d8
-rw-r--r--tests/unit/test_shell.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py
index 78da0dd..97ed293 100644
--- a/tests/unit/test_shell.py
+++ b/tests/unit/test_shell.py
@@ -174,6 +174,42 @@ class TestShell(unittest.TestCase):
@mock.patch('swiftclient.shell.OutputManager._print')
@mock.patch('swiftclient.service.Connection')
+ def test_list_account_long(self, connection, mock_print):
+ # Test account listing
+ connection.return_value.get_account.side_effect = [
+ [None, [{'name': 'container', 'bytes': 0, 'count': 0}]],
+ [None, []],
+ ]
+
+ argv = ["", "list", "--lh"]
+ swiftclient.shell.main(argv)
+ calls = [mock.call(marker='', prefix=None),
+ mock.call(marker='container', prefix=None)]
+ connection.return_value.get_account.assert_has_calls(calls)
+ calls = [mock.call(' 0 0 1970-01-01 00:00:01 container'),
+ mock.call(' 0 0')]
+ mock_print.assert_has_calls(calls)
+
+ # Now test again, this time without returning metadata
+ connection.return_value.head_container.return_value = {}
+
+ # Test account listing
+ connection.return_value.get_account.side_effect = [
+ [None, [{'name': 'container', 'bytes': 0, 'count': 0}]],
+ [None, []],
+ ]
+
+ argv = ["", "list", "--lh"]
+ swiftclient.shell.main(argv)
+ calls = [mock.call(marker='', prefix=None),
+ mock.call(marker='container', prefix=None)]
+ connection.return_value.get_account.assert_has_calls(calls)
+ calls = [mock.call(' 0 0 ????-??-?? ??:??:?? container'),
+ mock.call(' 0 0')]
+ mock_print.assert_has_calls(calls)
+
+ @mock.patch('swiftclient.shell.OutputManager._print')
+ @mock.patch('swiftclient.service.Connection')
def test_list_container(self, connection, mock_print):
connection.return_value.get_container.side_effect = [
[None, [{'name': 'object_a'}]],