Add parsing the endpoint URL

Add parsing the endpoint URL and check the path string only
in order to decide the API version.

Change-Id: Ib0a035f3bed31e2162a1231a5f5dcc3907d37243
Closes-Bug: #1489727
This commit is contained in:
Takashi NATSUME
2015-08-28 16:16:06 +09:00
parent 1e2274aef0
commit 19480df10a
2 changed files with 27 additions and 4 deletions
+20
View File
@@ -44,3 +44,23 @@ class ClientTest(testtools.TestCase):
gc = client.Client(2.2, "http://example.com/v2.1")
self.assertEqual("http://example.com", gc.http_client.endpoint)
self.assertIsInstance(gc, v2.client.Client)
def test_endpoint_with_version_hostname(self):
gc = client.Client(2, "http://v1.example.com")
self.assertEqual("http://v1.example.com", gc.http_client.endpoint)
self.assertIsInstance(gc, v2.client.Client)
def test_versioned_endpoint_with_version_hostname_v2(self):
gc = client.Client(endpoint="http://v1.example.com/v2")
self.assertEqual("http://v1.example.com", gc.http_client.endpoint)
self.assertIsInstance(gc, v2.client.Client)
def test_versioned_endpoint_with_version_hostname_v1(self):
gc = client.Client(endpoint="http://v2.example.com/v1")
self.assertEqual("http://v2.example.com", gc.http_client.endpoint)
self.assertIsInstance(gc, v1.client.Client)
def test_versioned_endpoint_with_minor_revision_and_version_hostname(self):
gc = client.Client(endpoint="http://v1.example.com/v2.1")
self.assertEqual("http://v1.example.com", gc.http_client.endpoint)
self.assertIsInstance(gc, v2.client.Client)