diff options
author | Cheng Li <shcli@cn.ibm.com> | 2016-05-31 14:32:58 +0800 |
---|---|---|
committer | Cheng Li <shcli@cn.ibm.com> | 2016-06-02 22:53:18 +0800 |
commit | 69bf4634b972ef2ee0ec1f015d71223203f0bb1a (patch) | |
tree | 7284f413432d077860a12634419a279deb7bd634 /tests/unit/test_shell.py | |
parent | f9d0657e70e9511a2d7b4c63bbf06b138dd0be5e (diff) | |
download | python-swiftclient-69bf4634b972ef2ee0ec1f015d71223203f0bb1a.tar.gz |
Add an option: disable etag check on downloads
This patch is to add an option of disable etag
check on downloads.
Change-Id: I9ad389dd691942dea6db470ca3f0543eb6e9703e
Closes-bug: #1581147
Diffstat (limited to 'tests/unit/test_shell.py')
-rw-r--r-- | tests/unit/test_shell.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py index d82def6..9001b45 100644 --- a/tests/unit/test_shell.py +++ b/tests/unit/test_shell.py @@ -367,6 +367,24 @@ class TestShell(unittest.TestCase): mock_open.assert_called_with('object', 'wb') self.assertEqual([], makedirs.mock_calls) + # Test downloading without md5 checks + objcontent = six.BytesIO(b'objcontent') + connection.return_value.get_object.side_effect = [ + ({'content-type': 'text/plain', + 'etag': '2cbbfe139a744d6abbe695e17f3c1991'}, + objcontent) + ] + with mock.patch(BUILTIN_OPEN) as mock_open, mock.patch( + 'swiftclient.service._SwiftReader') as sr: + argv = ["", "download", "container", "object", "--ignore-check"] + swiftclient.shell.main(argv) + connection.return_value.get_object.assert_called_with( + 'container', 'object', headers={}, resp_chunk_size=65536, + response_dict={}) + mock_open.assert_called_with('object', 'wb') + sr.assert_called_once_with('object', mock.ANY, mock.ANY, False) + self.assertEqual([], makedirs.mock_calls) + # Test downloading single object to stdout objcontent = six.BytesIO(b'objcontent') connection.return_value.get_object.side_effect = [ |