def test_get_bottom_url(self): b_endpoint = 'http://127.0.0.1:9696/v2.0/networks' t_url = 'http://127.0.0.1:9696/v2.0/networks' t_ver = hclient.get_version_from_url(t_url) b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(t_ver, 'v2.0') self.assertEqual(b_ver, 'v2.0') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks') b_endpoint = 'http://127.0.0.1:9696/v2.0' b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(b_ver, 'v2.0') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks') b_endpoint = 'http://127.0.0.1:9696/v2.0/' b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(b_ver, 'v2.0') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks') b_endpoint = 'http://127.0.0.1:9696/v2.0/' b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(b_ver, 'v2.0') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks')
def test_get_bottom_url(self): b_endpoint = 'http://127.0.0.1:8774/v2.1/$(tenant_id)s' t_url = 'http://127.0.0.1:8774/v2/my_tenant_id/volumes' t_ver = hclient.get_version_from_url(t_url) b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(t_ver, 'v2') self.assertEqual(b_ver, 'v2.1') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:8774/v2.1/my_tenant_id/volumes') b_endpoint = 'http://127.0.0.1:8774/' b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(b_ver, '') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:8774/my_tenant_id/volumes') b_endpoint = 'http://127.0.0.1:8774/v2.1' b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(b_ver, 'v2.1') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:8774/v2.1/my_tenant_id/volumes') b_endpoint = 'http://127.0.0.1:8774/v2.1/' b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(b_ver, 'v2.1') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:8774/v2.1/my_tenant_id/volumes')
def test_get_bottom_url(self): b_endpoint = 'http://127.0.0.1:9696/v2.0/networks' t_url = 'http://127.0.0.1:9696/v2.0/networks' t_ver = hclient.get_version_from_url(t_url) b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(t_ver, 'v2.0') self.assertEqual(b_ver, 'v2.0') t_url_1 = 'http://127.0.0.1:9696/sss/v2.0/networks' b_url = hclient.get_bottom_url(t_ver, t_url_1, b_ver, b_endpoint) self.assertEqual(b_url, '') t_url_1 = 'v2.0/networks' b_url = hclient.get_bottom_url(t_ver, t_url_1, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks') b_url = hclient.get_bottom_url(t_ver, t_url, '', b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/networks') t_url_1 = 'http://127.0.0.1:9696/v2.0/networks?qqq=123&sss=456' b_url = hclient.get_bottom_url(t_ver, t_url_1, b_ver, b_endpoint) self.assertEqual( b_url, 'http://127.0.0.1:9696/v2.0/networks?qqq=123&sss=456') t_url_1 = 'http://127.0.0.1:9696/v2.0/networks?' \ 'qqq=123&availability_zone=456' b_url = hclient.get_bottom_url(t_ver, t_url_1, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks?qqq=123') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks') b_endpoint = 'http://127.0.0.1:9696/v2.0' b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(b_ver, 'v2.0') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks') b_endpoint = 'http://127.0.0.1:9696/v2.0/' b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(b_ver, 'v2.0') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks') b_endpoint = 'http://127.0.0.1:9696/v2.0/' b_ver = hclient.get_version_from_url(b_endpoint) self.assertEqual(b_ver, 'v2.0') b_url = hclient.get_bottom_url(t_ver, t_url, b_ver, b_endpoint) self.assertEqual(b_url, 'http://127.0.0.1:9696/v2.0/networks')
def test_get_version_from_url(self): url = 'http://127.0.0.1:8774/v2.1/$(tenant_id)s' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.1') url = 'http://127.0.0.1:8774/v2.1/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.1') url = 'http://127.0.0.1:8774/v2.1/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.1') url = 'https://127.0.0.1:8774/v2.1/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.1') url = 'https://127.0.0.1/v2.1/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.1') url = 'https://127.0.0.1/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, '') url = 'https://127.0.0.1/sss/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'sss') url = '' ver = hclient.get_version_from_url(url) self.assertEqual(ver, '')
def test_get_version_from_url(self): url = 'http://127.0.0.1:9696/v2.0/networks' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.0') url = 'http://127.0.0.1:9696/v2.0/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.0') url = 'http://127.0.0.1:9696/v2.0/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.0') url = 'https://127.0.0.1:9696/v2.0/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.0') url = 'https://127.0.0.1/v2.0/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'v2.0') url = 'https://127.0.0.1/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, '') url = 'https://127.0.0.1/sss/' ver = hclient.get_version_from_url(url) self.assertEqual(ver, 'sss') url = '' ver = hclient.get_version_from_url(url) self.assertEqual(ver, '')