summaryrefslogtreecommitdiff
path: root/tests/unit/test_swiftclient.py
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hp.com>2015-02-23 11:09:39 +0000
committerAlistair Coles <alistair.coles@hp.com>2015-02-23 19:10:32 +0000
commit47f089fbcac5a587c3eef7dc7f83f6d476ababf9 (patch)
tree3e1e4f6e08c3d74f980bec11cc61dc66a880bb41 /tests/unit/test_swiftclient.py
parent45cce75e505043bc3aae0a7e889cb1272d80915b (diff)
downloadpython-swiftclient-47f089fbcac5a587c3eef7dc7f83f6d476ababf9.tar.gz
Include unsupported url scheme with ClientException
This was an attempt to reveal some more info about failing jenkins jobs such as here [1] where glance_store is receiving a swiftclient exception because of 'unsupported scheme in url'. It seems worth merging the more helpful exception message. [1] http://logs.openstack.org/91/155291/7/check/gate-tempest-dsvm-neutron-src-python-swiftclient/4adac1e/ Change-Id: I0f3411efd42d045b07d6d1000f59a06865d8034b
Diffstat (limited to 'tests/unit/test_swiftclient.py')
-rw-r--r--tests/unit/test_swiftclient.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py
index 0360016..931a216 100644
--- a/tests/unit/test_swiftclient.py
+++ b/tests/unit/test_swiftclient.py
@@ -975,6 +975,29 @@ class TestGetCapabilities(MockHttpTest):
class TestHTTPConnection(MockHttpTest):
+ def test_bad_url_scheme(self):
+ url = u'www.test.com'
+ exc = self.assertRaises(c.ClientException, c.http_connection, url)
+ expected = u'Unsupported scheme "" in url "www.test.com"'
+ self.assertEqual(expected, str(exc))
+
+ url = u'://www.test.com'
+ exc = self.assertRaises(c.ClientException, c.http_connection, url)
+ expected = u'Unsupported scheme "" in url "://www.test.com"'
+ self.assertEqual(expected, str(exc))
+
+ url = u'blah://www.test.com'
+ exc = self.assertRaises(c.ClientException, c.http_connection, url)
+ expected = u'Unsupported scheme "blah" in url "blah://www.test.com"'
+ self.assertEqual(expected, str(exc))
+
+ def test_ok_url_scheme(self):
+ for scheme in ('http', 'https', 'HTTP', 'HTTPS'):
+ url = u'%s://www.test.com' % scheme
+ parsed_url, conn = c.http_connection(url)
+ self.assertEqual(scheme.lower(), parsed_url.scheme)
+ self.assertEqual(u'%s://www.test.com' % scheme, conn.url)
+
def test_ok_proxy(self):
conn = c.http_connection(u'http://www.test.com/',
proxy='http://localhost:8080')