diff options
Diffstat (limited to 'tests/test_swiftclient.py')
-rw-r--r-- | tests/test_swiftclient.py | 28 |
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) |