Fix urllib.urlencode issue in functional tests on Python 3
The urllib, urllib2, and urlparse modules have been combined in the urllib package in Python 3. The six.moves.urllib package is a version-independent location for this functionality; its structure mimics the structure of the Python 3 urllib package. Partially-Implements: blueprint goal-python35 Change-Id: I423d334bd7d2be5fae19007ddb6408eca381a6bd
This commit is contained in:
@@ -12,12 +12,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import urllib
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import requests
|
import requests
|
||||||
import six
|
import six
|
||||||
|
from six.moves.urllib import parse
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@@ -259,7 +258,7 @@ class TestOpenStackClient(object):
|
|||||||
for opt, val in six.iteritems(search_opts):
|
for opt, val in six.iteritems(search_opts):
|
||||||
qparams[opt] = val
|
qparams[opt] = val
|
||||||
if qparams:
|
if qparams:
|
||||||
query_string = "?%s" % urllib.urlencode(qparams)
|
query_string = "?%s" % parse.urlencode(qparams)
|
||||||
rel_url += query_string
|
rel_url += query_string
|
||||||
return self.api_get(rel_url).body['servers']
|
return self.api_get(rel_url).body['servers']
|
||||||
|
|
||||||
|
@@ -13,10 +13,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import urllib
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from six.moves.urllib import parse
|
||||||
|
|
||||||
from nova.tests.functional.api_sample_tests import test_servers
|
from nova.tests.functional.api_sample_tests import test_servers
|
||||||
import nova.tests.functional.api_samples_test_base as astb
|
import nova.tests.functional.api_samples_test_base as astb
|
||||||
@@ -49,7 +49,7 @@ class SimpleTenantUsageSampleJsonTest(test_servers.ServersSampleBase):
|
|||||||
def test_get_tenants_usage(self):
|
def test_get_tenants_usage(self):
|
||||||
# Get api sample to get all tenants usage request.
|
# Get api sample to get all tenants usage request.
|
||||||
response = self._do_get('os-simple-tenant-usage?%s' % (
|
response = self._do_get('os-simple-tenant-usage?%s' % (
|
||||||
urllib.urlencode(self.query)))
|
parse.urlencode(self.query)))
|
||||||
self._verify_response('simple-tenant-usage-get', {}, response, 200)
|
self._verify_response('simple-tenant-usage-get', {}, response, 200)
|
||||||
|
|
||||||
def test_get_tenants_usage_with_detail(self):
|
def test_get_tenants_usage_with_detail(self):
|
||||||
@@ -57,7 +57,7 @@ class SimpleTenantUsageSampleJsonTest(test_servers.ServersSampleBase):
|
|||||||
query = self.query.copy()
|
query = self.query.copy()
|
||||||
query.update({'detailed': 1})
|
query.update({'detailed': 1})
|
||||||
response = self._do_get('os-simple-tenant-usage?%s' % (
|
response = self._do_get('os-simple-tenant-usage?%s' % (
|
||||||
urllib.urlencode(query)))
|
parse.urlencode(query)))
|
||||||
self._verify_response('simple-tenant-usage-get-detail', {},
|
self._verify_response('simple-tenant-usage-get-detail', {},
|
||||||
response, 200)
|
response, 200)
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ class SimpleTenantUsageSampleJsonTest(test_servers.ServersSampleBase):
|
|||||||
# Get api sample to get specific tenant usage request.
|
# Get api sample to get specific tenant usage request.
|
||||||
tenant_id = astb.PROJECT_ID
|
tenant_id = astb.PROJECT_ID
|
||||||
response = self._do_get('os-simple-tenant-usage/%s?%s' % (tenant_id,
|
response = self._do_get('os-simple-tenant-usage/%s?%s' % (tenant_id,
|
||||||
urllib.urlencode(self.query)))
|
parse.urlencode(self.query)))
|
||||||
self._verify_response('simple-tenant-usage-get-specific', {},
|
self._verify_response('simple-tenant-usage-get-specific', {},
|
||||||
response, 200)
|
response, 200)
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ class SimpleTenantUsageV240Test(test_servers.ServersSampleBase):
|
|||||||
|
|
||||||
def test_get_tenants_usage(self):
|
def test_get_tenants_usage(self):
|
||||||
url = 'os-simple-tenant-usage?%s'
|
url = 'os-simple-tenant-usage?%s'
|
||||||
response = self._do_get(url % (urllib.urlencode(self.query)))
|
response = self._do_get(url % (parse.urlencode(self.query)))
|
||||||
template_name = 'simple-tenant-usage-get'
|
template_name = 'simple-tenant-usage-get'
|
||||||
self._verify_response(template_name, {}, response, 200)
|
self._verify_response(template_name, {}, response, 200)
|
||||||
|
|
||||||
@@ -113,14 +113,14 @@ class SimpleTenantUsageV240Test(test_servers.ServersSampleBase):
|
|||||||
query = self.query.copy()
|
query = self.query.copy()
|
||||||
query.update({'detailed': 1})
|
query.update({'detailed': 1})
|
||||||
url = 'os-simple-tenant-usage?%s'
|
url = 'os-simple-tenant-usage?%s'
|
||||||
response = self._do_get(url % (urllib.urlencode(query)))
|
response = self._do_get(url % (parse.urlencode(query)))
|
||||||
template_name = 'simple-tenant-usage-get-detail'
|
template_name = 'simple-tenant-usage-get-detail'
|
||||||
self._verify_response(template_name, {}, response, 200)
|
self._verify_response(template_name, {}, response, 200)
|
||||||
|
|
||||||
def test_get_tenant_usage_details(self):
|
def test_get_tenant_usage_details(self):
|
||||||
tenant_id = astb.PROJECT_ID
|
tenant_id = astb.PROJECT_ID
|
||||||
url = 'os-simple-tenant-usage/{tenant}?%s'.format(tenant=tenant_id)
|
url = 'os-simple-tenant-usage/{tenant}?%s'.format(tenant=tenant_id)
|
||||||
response = self._do_get(url % (urllib.urlencode(self.query)))
|
response = self._do_get(url % (parse.urlencode(self.query)))
|
||||||
template_name = 'simple-tenant-usage-get-specific'
|
template_name = 'simple-tenant-usage-get-specific'
|
||||||
subs = {'tenant_id': self.api.project_id}
|
subs = {'tenant_id': self.api.project_id}
|
||||||
self._verify_response(template_name, subs, response, 200)
|
self._verify_response(template_name, subs, response, 200)
|
||||||
|
@@ -472,15 +472,8 @@ nova.tests.functional.db.test_resource_provider.ResourceProviderTestCase.test_up
|
|||||||
nova.tests.functional.db.test_resource_provider.TestAllocationListCreateDelete.test_allocation_list_create
|
nova.tests.functional.db.test_resource_provider.TestAllocationListCreateDelete.test_allocation_list_create
|
||||||
nova.tests.functional.db.test_compute_node.ComputeNodeTestCase.test_recreate_rp
|
nova.tests.functional.db.test_compute_node.ComputeNodeTestCase.test_recreate_rp
|
||||||
nova.tests.functional.db.test_resource_provider.ResourceProviderTestCase.test_save_resource_provider
|
nova.tests.functional.db.test_resource_provider.ResourceProviderTestCase.test_save_resource_provider
|
||||||
nova.tests.functional.notification_sample_tests.test_instance.TestInstanceNotificationSample.test_instance_action
|
|
||||||
nova.tests.functional.regressions.test_bug_1554631.TestCinderForbidden.test_forbidden_cinder_operation_returns_403
|
nova.tests.functional.regressions.test_bug_1554631.TestCinderForbidden.test_forbidden_cinder_operation_returns_403
|
||||||
nova.tests.functional.regressions.test_bug_1554631.TestCinderOverLimit.test_over_limit_snapshots_force
|
nova.tests.functional.regressions.test_bug_1554631.TestCinderOverLimit.test_over_limit_snapshots_force
|
||||||
nova.tests.functional.notification_sample_tests.test_instance.TestInstanceNotificationSample.test_create_delete_server_with_instance_update
|
|
||||||
nova.tests.functional.notification_sample_tests.test_instance.TestInstanceNotificationSample.test_volume_swap_server
|
|
||||||
nova.tests.functional.notification_sample_tests.test_instance.TestInstanceNotificationSample.test_create_delete_server
|
|
||||||
nova.tests.functional.notification_sample_tests.test_instance.TestInstanceNotificationSample.test_create_server_error
|
|
||||||
nova.tests.functional.notification_sample_tests.test_instance.TestInstanceNotificationSample.test_volume_swap_server_with_error
|
|
||||||
nova.tests.functional.regressions.test_bug_1548980.TestServerGet.test_list_deleted_instances
|
|
||||||
nova.tests.functional.regressions.test_bug_1554631.TestCinderOverLimit.test_over_limit_volumes
|
nova.tests.functional.regressions.test_bug_1554631.TestCinderOverLimit.test_over_limit_volumes
|
||||||
nova.tests.functional.regressions.test_bug_1554631.TestCinderOverLimit.test_over_limit_snapshots
|
nova.tests.functional.regressions.test_bug_1554631.TestCinderOverLimit.test_over_limit_snapshots
|
||||||
nova.tests.functional.test_server_group.ServerGroupTestV21.test_evacuate_with_affinity_no_valid_host
|
nova.tests.functional.test_server_group.ServerGroupTestV21.test_evacuate_with_affinity_no_valid_host
|
||||||
@@ -489,7 +482,6 @@ nova.tests.functional.test_server_group.ServerGroupTestV21.test_evacuate_with_an
|
|||||||
nova.tests.functional.test_server_group.ServerGroupTestV215.test_evacuate_with_affinity_no_valid_host
|
nova.tests.functional.test_server_group.ServerGroupTestV215.test_evacuate_with_affinity_no_valid_host
|
||||||
nova.tests.functional.test_server_group.ServerGroupTestV215.test_evacuate_with_anti_affinity_no_valid_host
|
nova.tests.functional.test_server_group.ServerGroupTestV215.test_evacuate_with_anti_affinity_no_valid_host
|
||||||
nova.tests.functional.test_server_group.ServerGroupTestV215.test_evacuate_with_soft_affinity
|
nova.tests.functional.test_server_group.ServerGroupTestV215.test_evacuate_with_soft_affinity
|
||||||
nova.tests.functional.test_servers.ServersTest.test_create_multiple_servers
|
|
||||||
nova.tests.functional.test_server_group.ServerGroupTestV215.test_evacuate_with_soft_anti_affinity
|
nova.tests.functional.test_server_group.ServerGroupTestV215.test_evacuate_with_soft_anti_affinity
|
||||||
nova.tests.functional.test_servers.ServersTestV21.test_create_server_with_injected_files
|
nova.tests.functional.test_servers.ServersTestV21.test_create_server_with_injected_files
|
||||||
nova.tests.functional.test_servers.ServersTest.test_create_server_with_injected_files
|
nova.tests.functional.test_servers.ServersTest.test_create_server_with_injected_files
|
||||||
|
Reference in New Issue
Block a user