示例#1
0
    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')
示例#2
0
    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')
示例#3
0
    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')
示例#4
0
    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, '')
示例#5
0
    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, '')
示例#6
0
    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, '')
示例#7
0
    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')