diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-06-06 10:33:25 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-06-06 10:33:25 +0000 |
commit | c91c8d575e86b480270f8dfb7df49355dd38ee54 (patch) | |
tree | ee60b5dfa7a88a2e607c02f84a885ac4b1fa99d2 /tests | |
parent | e1e2678cd0a99955c280a813e10c6ce7494389cd (diff) | |
parent | 69bf4634b972ef2ee0ec1f015d71223203f0bb1a (diff) | |
download | python-swiftclient-c91c8d575e86b480270f8dfb7df49355dd38ee54.tar.gz |
Merge "Add an option: disable etag check on downloads"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_service.py | 9 | ||||
-rw-r--r-- | tests/unit/test_shell.py | 18 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py index cce8c7a..75f8961 100644 --- a/tests/unit/test_service.py +++ b/tests/unit/test_service.py @@ -103,6 +103,15 @@ class TestSwiftReader(unittest.TestCase): self.assertEqual(sr._expected_etag, None) self.assertEqual(sr._actual_md5, None) + def test_create_with_ignore_checksum(self): + # md5 should not be initialized if checksum is False + sr = self.sr('path', 'body', {}, False) + self.assertEqual(sr._path, 'path') + self.assertEqual(sr._body, 'body') + self.assertEqual(sr._content_length, None) + self.assertEqual(sr._expected_etag, None) + self.assertEqual(sr._actual_md5, None) + def test_create_with_content_length(self): sr = self.sr('path', 'body', {'content-length': 5}) diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py index 0639ac1..59f0d5f 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 = [ |