summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTimur Alperovich <timuralp@swiftstack.com>2018-03-05 17:33:22 -0800
committerTimur Alperovich <timuralp@swiftstack.com>2018-03-05 17:33:22 -0800
commita36c3cfda1c243273fcd11b9e123aca877869244 (patch)
tree18ef07bf58f05bc3a830c05711736a720ee4ad70 /tests
parent73f0259dbc847eee027f76a9e867fe8c53bf9918 (diff)
downloadpython-swiftclient-a36c3cfda1c243273fcd11b9e123aca877869244.tar.gz
Add a query_string option to head_object().
Submitting a path parameter with a HEAD request on an object can be useful if one is trying to find out information about an SLO/DLO without retrieving the manifest. Change-Id: I39efd098e72bd31de271ac51d4d75381929c9638
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_swiftclient.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py
index 3de5f02..7b8628b 100644
--- a/tests/unit/test_swiftclient.py
+++ b/tests/unit/test_swiftclient.py
@@ -1180,6 +1180,16 @@ class TestHeadObject(MockHttpTest):
}),
])
+ def test_query_string(self):
+ c.http_connection = self.fake_http_connection(204)
+ conn = c.http_connection('http://www.test.com')
+ query_string = 'foo=bar'
+ c.head_object('url_is_irrelevant', 'token', 'container', 'key',
+ http_conn=conn, query_string=query_string)
+ self.assertRequests([
+ ('HEAD', '/container/key?foo=bar', '', {'x-auth-token': 'token'})
+ ])
+
class TestPutObject(MockHttpTest):
@@ -2459,16 +2469,17 @@ class TestConnection(MockHttpTest):
def test_head_object(self):
headers = {'X-Favourite-Pet': 'Aardvark'}
+ query_string = 'foo=bar'
with mock.patch('swiftclient.client.http_connection',
self.fake_http_connection(200)):
with mock.patch('swiftclient.client.get_auth',
lambda *a, **k: ('http://url:8080/v1/a', 'token')):
conn = c.Connection()
conn.head_object('c1', 'o1',
- headers=headers)
+ headers=headers, query_string=query_string)
self.assertEqual(1, len(self.request_log), self.request_log)
self.assertRequests([
- ('HEAD', '/v1/a/c1/o1', '', {
+ ('HEAD', '/v1/a/c1/o1?foo=bar', '', {
'x-auth-token': 'token',
'X-Favourite-Pet': 'Aardvark',
}),