summaryrefslogtreecommitdiff
path: root/tests/unit/test_swiftclient.py
diff options
context:
space:
mode:
authorAndrew Welleck <awellec@us.ibm.com>2016-02-23 15:02:03 -0600
committerAndrew Welleck <awellec@us.ibm.com>2016-06-09 13:51:26 -0500
commit439330cb9caa88d455ee0770d32ad7bc77db0b2a (patch)
tree97f36b30f6724b50e61bef1df4f38eceb4fbade2 /tests/unit/test_swiftclient.py
parent3a6c14981dbd26e12b7d77ebfbb501607557b97c (diff)
downloadpython-swiftclient-439330cb9caa88d455ee0770d32ad7bc77db0b2a.tar.gz
Query string functionality for containers
Added functionality for arbitrary query strings to be passed into container functions. Additionally a minor typo correction in the README. Added unit tests for query string functionality. Closes-Bug: #1542459 Change-Id: Ica2cb3ea439632588388e748d8d2e944e9ed4fa4
Diffstat (limited to 'tests/unit/test_swiftclient.py')
-rw-r--r--tests/unit/test_swiftclient.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py
index a51fe1a..dda37fd 100644
--- a/tests/unit/test_swiftclient.py
+++ b/tests/unit/test_swiftclient.py
@@ -746,6 +746,16 @@ class TestGetContainer(MockHttpTest):
}),
])
+ def test_query_string(self):
+ c.http_connection = self.fake_http_connection(
+ 200, query_string="format=json&hello=20", body=b'[]')
+ c.get_container('http://www.test.com', 'asdf', 'asdf',
+ query_string="hello=20")
+ self.assertRequests([
+ ('GET', '/asdf?format=json&hello=20', '', {
+ 'x-auth-token': 'asdf'}),
+ ])
+
class TestHeadContainer(MockHttpTest):
@@ -805,6 +815,17 @@ class TestPutContainer(MockHttpTest):
'content-length': '0'}),
])
+ def test_query_string(self):
+ c.http_connection = self.fake_http_connection(200,
+ query_string="hello=20")
+ c.put_container('http://www.test.com', 'asdf', 'asdf',
+ query_string="hello=20")
+ for req in self.iter_request_log():
+ self.assertEqual(req['method'], 'PUT')
+ self.assertEqual(req['parsed_path'].path, '/asdf')
+ self.assertEqual(req['parsed_path'].query, 'hello=20')
+ self.assertEqual(req['headers']['x-auth-token'], 'asdf')
+
class TestDeleteContainer(MockHttpTest):
@@ -817,6 +838,16 @@ class TestDeleteContainer(MockHttpTest):
'x-auth-token': 'token'}),
])
+ def test_query_string(self):
+ c.http_connection = self.fake_http_connection(200,
+ query_string="hello=20")
+ c.delete_container('http://www.test.com', 'token', 'container',
+ query_string="hello=20")
+ self.assertRequests([
+ ('DELETE', 'http://www.test.com/container?hello=20', '', {
+ 'x-auth-token': 'token'})
+ ])
+
class TestGetObject(MockHttpTest):