summaryrefslogtreecommitdiff
path: root/tests/unit/test_service.py
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2016-04-08 13:29:37 -0700
committerTim Burke <tim.burke@gmail.com>2016-04-08 13:41:29 -0700
commit4a6fa02c2832086d3ea5f7fff694c844da980928 (patch)
treef6fe73916b04cdfdd67b076b73f0a10f39257f03 /tests/unit/test_service.py
parent015903e383a27318918ee7827574ecb120110ae2 (diff)
downloadpython-swiftclient-4a6fa02c2832086d3ea5f7fff694c844da980928.tar.gz
Identify segments uploaded via swiftclient
...using a new "application/swiftclient-segment" content-type. Segments uploaded by swiftclient are expected to have a many-to-one relationship to large objects, rather than the more-general many-to-many relationship that SLO and DLO generally allow. Later, we may use this information to make more intelligent decisions, such as when to automatically clean up segments. Change-Id: Ie56a3aa10065db754ac572cc37d93f2c901aac60
Diffstat (limited to 'tests/unit/test_service.py')
-rw-r--r--tests/unit/test_service.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py
index e9310aa..d8de581 100644
--- a/tests/unit/test_service.py
+++ b/tests/unit/test_service.py
@@ -945,11 +945,12 @@ class TestServiceUpload(_TestServiceBase):
self.assertEqual(r, expected_r)
self.assertEqual(mock_conn.put_object.call_count, 1)
- mock_conn.put_object.assert_called_with('test_c_segments',
- 'test_s_1',
- mock.ANY,
- content_length=10,
- response_dict={})
+ mock_conn.put_object.assert_called_with(
+ 'test_c_segments', 'test_s_1',
+ mock.ANY,
+ content_length=10,
+ content_type='application/swiftclient-segment',
+ response_dict={})
contents = mock_conn.put_object.call_args[0][2]
self.assertIsInstance(contents, utils.LengthWrapper)
self.assertEqual(len(contents), 10)
@@ -988,11 +989,12 @@ class TestServiceUpload(_TestServiceBase):
self.assertIsNone(r.get('error'))
self.assertEqual(mock_conn.put_object.call_count, 1)
- mock_conn.put_object.assert_called_with('test_c_segments',
- 'test_s_1',
- mock.ANY,
- content_length=10,
- response_dict={})
+ mock_conn.put_object.assert_called_with(
+ 'test_c_segments', 'test_s_1',
+ mock.ANY,
+ content_length=10,
+ content_type='application/swiftclient-segment',
+ response_dict={})
contents = mock_conn.put_object.call_args[0][2]
# Check that md5sum is not calculated.
self.assertEqual(contents.get_md5sum(), '')
@@ -1028,11 +1030,12 @@ class TestServiceUpload(_TestServiceBase):
self.assertIn('md5 mismatch', str(r.get('error')))
self.assertEqual(mock_conn.put_object.call_count, 1)
- mock_conn.put_object.assert_called_with('test_c_segments',
- 'test_s_1',
- mock.ANY,
- content_length=10,
- response_dict={})
+ mock_conn.put_object.assert_called_with(
+ 'test_c_segments', 'test_s_1',
+ mock.ANY,
+ content_length=10,
+ content_type='application/swiftclient-segment',
+ response_dict={})
contents = mock_conn.put_object.call_args[0][2]
self.assertEqual(contents.get_md5sum(), md5(b'b' * 10).hexdigest())