From 69bf4634b972ef2ee0ec1f015d71223203f0bb1a Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Tue, 31 May 2016 14:32:58 +0800 Subject: 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 --- tests/unit/test_shell.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/unit/test_shell.py') 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 = [ -- cgit v1.2.1