summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-01-31 08:55:27 +0000
committerGerrit Code Review <review@openstack.org>2014-01-31 08:55:27 +0000
commitfeb514a207f486f0f71ec575d640e4b0dcb9b1ad (patch)
tree00dad64ffce02350523a824e2cdfdee26ad8134d /tests
parent95aa3e96f25137d5e6716d0a4572b8885b0cd11a (diff)
parent533c9c5ba14581ac06b31f82531f9c749d489868 (diff)
downloadpython-swiftclient-feb514a207f486f0f71ec575d640e4b0dcb9b1ad.tar.gz
Merge "Add capabilities option"
Diffstat (limited to 'tests')
-rw-r--r--tests/test_swiftclient.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py
index 6c680d6..19764db 100644
--- a/tests/test_swiftclient.py
+++ b/tests/test_swiftclient.py
@@ -656,6 +656,20 @@ class TestDeleteObject(MockHttpTest):
query_string="hello=20")
+class TestGetCapabilities(MockHttpTest):
+
+ def test_ok(self):
+ conn = self.fake_http_connection(200, body='{}')
+ http_conn = conn('http://www.test.com/info')
+ self.assertEqual(type(c.get_capabilities(http_conn)), dict)
+ self.assertTrue(http_conn[1].has_been_read)
+
+ def test_server_error(self):
+ conn = self.fake_http_connection(500)
+ http_conn = conn('http://www.test.com/info')
+ self.assertRaises(c.ClientException, c.get_capabilities, http_conn)
+
+
class TestConnection(MockHttpTest):
def test_instance(self):
@@ -703,6 +717,20 @@ class TestConnection(MockHttpTest):
for method, args in method_signatures:
method(*args)
+ def test_get_capabilities(self):
+ conn = c.Connection()
+ with mock.patch('swiftclient.client.get_capabilities') as get_cap:
+ conn.get_capabilities('http://storage2.test.com')
+ parsed = get_cap.call_args[0][0][0]
+ self.assertEqual(parsed.path, '/info')
+ self.assertEqual(parsed.netloc, 'storage2.test.com')
+ conn.get_auth = lambda: ('http://storage.test.com/v1/AUTH_test',
+ 'token')
+ conn.get_capabilities()
+ parsed = get_cap.call_args[0][0][0]
+ self.assertEqual(parsed.path, '/info')
+ self.assertEqual(parsed.netloc, 'storage.test.com')
+
def test_retry(self):
c.http_connection = self.fake_http_connection(500)