diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-04-29 21:45:27 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-04-29 21:45:28 +0000 |
commit | b1ca7056b106638151f8bde45a4c7764633c139b (patch) | |
tree | 9b0c32b9d6b57d1d09a8335f10d0608969712856 | |
parent | 9ff3bad4e22fbd561d9253af2b6e38580124b450 (diff) | |
parent | 0fc27f6c2809abbca4927ab59d11e9a623a23f89 (diff) | |
download | python-swiftclient-b1ca7056b106638151f8bde45a4c7764633c139b.tar.gz |
Merge "Mock auth_end_time in test_shell.test_download"
-rw-r--r-- | tests/test_shell.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/test_shell.py b/tests/test_shell.py index 5708b97..61d970d 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -172,9 +172,8 @@ class TestShell(unittest.TestCase): mock.call(' 0')] mock_print.assert_has_calls(calls) - @mock.patch(BUILTIN_OPEN) @mock.patch('swiftclient.shell.Connection') - def test_download(self, connection, mock_open): + def test_download(self, connection): connection.return_value.get_object.return_value = [ {'content-type': 'text/plain', 'etag': 'd41d8cd98f00b204e9800998ecf8427e'}, @@ -185,18 +184,23 @@ class TestShell(unittest.TestCase): [None, [{'name': 'object'}]], [None, []], ] + connection.return_value.auth_end_time = 0 connection.return_value.attempts = 0 - argv = ["", "download", "container"] - swiftclient.shell.main(argv) - connection.return_value.get_object.assert_called_with( - 'container', 'object', headers={}, resp_chunk_size=65536) + with mock.patch(BUILTIN_OPEN) as mock_open: + argv = ["", "download", "container"] + swiftclient.shell.main(argv) + connection.return_value.get_object.assert_called_with( + 'container', 'object', headers={}, resp_chunk_size=65536) + mock_open.assert_called_with('object', 'wb') # Test downloading single object - argv = ["", "download", "container", "object"] - swiftclient.shell.main(argv) - connection.return_value.get_object.assert_called_with( - 'container', 'object', headers={}, resp_chunk_size=65536) + with mock.patch(BUILTIN_OPEN) as mock_open: + argv = ["", "download", "container", "object"] + swiftclient.shell.main(argv) + connection.return_value.get_object.assert_called_with( + 'container', 'object', headers={}, resp_chunk_size=65536) + mock_open.assert_called_with('object', 'wb') @mock.patch('swiftclient.shell.listdir') @mock.patch('swiftclient.shell.Connection') |