summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-03-10 12:24:44 +0000
committerGerrit Code Review <review@openstack.org>2022-03-10 12:24:44 +0000
commit52a1025047b2d8f82a88369da243fa72b1bd9b20 (patch)
tree33c68be534ec887b64c147c00e0bffab67cee581
parentcf9a30d39ee7759c15340eb90ed2d13f326ebf32 (diff)
parente4444e69790a117ef821e0a9af3dcff4e16095eb (diff)
downloadhorizon-52a1025047b2d8f82a88369da243fa72b1bd9b20.tar.gz
Merge "Address RemovedInDjango40Warning (4)"
-rw-r--r--horizon/tables/base.py6
-rw-r--r--openstack_dashboard/api/rest/nova.py7
-rw-r--r--openstack_dashboard/api/rest/swift.py4
-rw-r--r--openstack_dashboard/dashboards/admin/backups/tests.py5
-rw-r--r--openstack_dashboard/dashboards/admin/networks/subnets/tests.py6
-rw-r--r--openstack_dashboard/dashboards/admin/networks/tests.py26
-rw-r--r--openstack_dashboard/dashboards/admin/snapshots/tests.py6
-rw-r--r--openstack_dashboard/dashboards/admin/volumes/tests.py4
-rw-r--r--openstack_dashboard/dashboards/project/backups/tests.py5
-rw-r--r--openstack_dashboard/dashboards/project/networks/tests.py26
-rw-r--r--openstack_dashboard/dashboards/project/snapshots/tests.py4
-rw-r--r--openstack_dashboard/dashboards/project/volume_groups/tests.py6
-rw-r--r--openstack_dashboard/dashboards/project/volumes/tests.py4
-rw-r--r--openstack_dashboard/test/helpers.py6
-rw-r--r--openstack_dashboard/test/test_data/swift_data.py8
15 files changed, 63 insertions, 60 deletions
diff --git a/horizon/tables/base.py b/horizon/tables/base.py
index f833d4e92..8de69623c 100644
--- a/horizon/tables/base.py
+++ b/horizon/tables/base.py
@@ -20,6 +20,7 @@ import json
import logging
from operator import attrgetter
import sys
+from urllib import parse
from django.conf import settings
from django.core import exceptions as core_exceptions
@@ -32,7 +33,6 @@ from django.template.loader import render_to_string
from django import urls
from django.utils import encoding
from django.utils.html import escape
-from django.utils import http
from django.utils.http import urlencode
from django.utils.safestring import mark_safe
from django.utils import termcolors
@@ -1861,7 +1861,7 @@ class DataTable(object, metaclass=DataTableMetaclass):
The return value will be used as marker/limit-based paging in the API.
"""
- return http.urlquote_plus(self.get_object_id(self.data[0])) \
+ return parse.quote_plus(self.get_object_id(self.data[0])) \
if self.data else ''
def get_marker(self):
@@ -1869,7 +1869,7 @@ class DataTable(object, metaclass=DataTableMetaclass):
The return value will be used as marker/limit-based paging in the API.
"""
- return http.urlquote_plus(self.get_object_id(self.data[-1])) \
+ return parse.quote_plus(self.get_object_id(self.data[-1])) \
if self.data else ''
def get_prev_pagination_string(self):
diff --git a/openstack_dashboard/api/rest/nova.py b/openstack_dashboard/api/rest/nova.py
index db02e5815..fb6f7bdbe 100644
--- a/openstack_dashboard/api/rest/nova.py
+++ b/openstack_dashboard/api/rest/nova.py
@@ -13,6 +13,7 @@
# limitations under the License.
"""API over the nova service."""
from collections import OrderedDict
+from urllib import parse
from django.utils import http as utils_http
from django.utils.translation import gettext_lazy as _
@@ -91,7 +92,7 @@ class Keypairs(generic.View):
request.DATA['name'],
request.DATA['key_type'])
return rest_utils.CreatedResponse(
- '/api/nova/keypairs/%s' % utils_http.urlquote(new.name),
+ '/api/nova/keypairs/%s' % parse.quote(new.name),
new.to_dict()
)
@@ -380,7 +381,7 @@ class Servers(generic.View):
new = api.nova.server_create(*args, **kw)
return rest_utils.CreatedResponse(
- '/api/nova/servers/%s' % utils_http.urlquote(new.id),
+ '/api/nova/servers/%s' % parse.quote(new.id),
new.to_dict()
)
@@ -445,7 +446,7 @@ class ServerGroups(generic.View):
"""
new_servergroup = api.nova.server_group_create(request, **request.DATA)
return rest_utils.CreatedResponse(
- '/api/nova/servergroups/%s' % utils_http.urlquote(
+ '/api/nova/servergroups/%s' % parse.quote(
new_servergroup.id), new_servergroup.to_dict()
)
diff --git a/openstack_dashboard/api/rest/swift.py b/openstack_dashboard/api/rest/swift.py
index f00d10c97..d59037973 100644
--- a/openstack_dashboard/api/rest/swift.py
+++ b/openstack_dashboard/api/rest/swift.py
@@ -14,10 +14,10 @@
"""API for the swift service."""
import os
+from urllib import parse
from django import forms
from django.http import StreamingHttpResponse
-from django.utils.http import urlunquote
from django.views.decorators.csrf import csrf_exempt
from django.views import generic
@@ -148,7 +148,7 @@ class Objects(generic.View):
"""
path = request.GET.get('path')
if path is not None:
- path = urlunquote(path)
+ path = parse.unquote(path)
objects = api.swift.swift_get_objects(
request,
diff --git a/openstack_dashboard/dashboards/admin/backups/tests.py b/openstack_dashboard/dashboards/admin/backups/tests.py
index 060614636..c247ab460 100644
--- a/openstack_dashboard/dashboards/admin/backups/tests.py
+++ b/openstack_dashboard/dashboards/admin/backups/tests.py
@@ -10,11 +10,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from urllib import parse
+
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.http import urlencode
-from django.utils.http import urlunquote
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.backups \
@@ -40,7 +41,7 @@ class AdminVolumeBackupsViewTests(test.BaseAdminViewTests):
= self.cinder_volume_snapshots.list()
self.mock_tenant_list.return_value = [self.tenants.list(), False]
- res = self.client.get(urlunquote(url))
+ res = self.client.get(parse.unquote(url))
self.assertEqual(res.status_code, 200)
self.assertTemplateUsed(res, 'horizon/common/_data_table_view.html')
diff --git a/openstack_dashboard/dashboards/admin/networks/subnets/tests.py b/openstack_dashboard/dashboards/admin/networks/subnets/tests.py
index 155054356..4f9478d53 100644
--- a/openstack_dashboard/dashboards/admin/networks/subnets/tests.py
+++ b/openstack_dashboard/dashboards/admin/networks/subnets/tests.py
@@ -15,6 +15,7 @@
import collections
from unittest import mock
+from urllib import parse
from django.urls import reverse
@@ -410,9 +411,8 @@ class NetworkSubnetTests(test.BaseAdminViewTests):
self.mock_subnet_list.return_value = [self.subnets.first()]
self.mock_tenant_quota_usages.return_value = quota_data
- from django.utils.http import urlunquote
- url = urlunquote(reverse('horizon:admin:networks:subnets_tab',
- args=[network.id]))
+ url = parse.unquote(reverse('horizon:admin:networks:subnets_tab',
+ args=[network.id]))
res = self.client.get(url)
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
subnets = res.context['subnets_table'].data
diff --git a/openstack_dashboard/dashboards/admin/networks/tests.py b/openstack_dashboard/dashboards/admin/networks/tests.py
index f2ac0b2ce..7f7973c9e 100644
--- a/openstack_dashboard/dashboards/admin/networks/tests.py
+++ b/openstack_dashboard/dashboards/admin/networks/tests.py
@@ -14,9 +14,9 @@
import collections
from unittest import mock
+from urllib import parse
from django.urls import reverse
-from django.utils.http import urlunquote
from horizon import forms
@@ -123,8 +123,8 @@ class NetworkTests(test.BaseAdminViewTests):
'mac-learning': mac_learning,
'dhcp_agent_scheduler': True})
- url = urlunquote(reverse('horizon:admin:networks:detail',
- args=[network.id]))
+ url = parse.unquote(reverse('horizon:admin:networks:detail',
+ args=[network.id]))
res = self.client.get(url)
network = res.context['network']
@@ -171,8 +171,8 @@ class NetworkTests(test.BaseAdminViewTests):
'dhcp_agent_scheduler': True})
self.mock_tenant_quota_usages.return_value = quota_data
- url = urlunquote(reverse('horizon:admin:networks:subnets_tab',
- args=[network.id]))
+ url = parse.unquote(reverse('horizon:admin:networks:subnets_tab',
+ args=[network.id]))
res = self.client.get(url)
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
@@ -215,7 +215,7 @@ class NetworkTests(test.BaseAdminViewTests):
url = reverse('horizon:admin:networks:ports_tab',
args=[network.id])
- res = self.client.get(urlunquote(url))
+ res = self.client.get(parse.unquote(url))
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
ports = res.context['ports_table'].data
@@ -260,7 +260,7 @@ class NetworkTests(test.BaseAdminViewTests):
self.mock_tenant_quota_usages.return_value = quota_data
url = reverse('horizon:admin:networks:agents_tab', args=[network.id])
- res = self.client.get(urlunquote(url))
+ res = self.client.get(parse.unquote(url))
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
result_agents = res.context['agents_table'].data
@@ -304,8 +304,8 @@ class NetworkTests(test.BaseAdminViewTests):
{'network-ip-availability': True,
'mac-learning': mac_learning})
- url = urlunquote(reverse('horizon:admin:networks:subnets_tab',
- args=[network_id]))
+ url = parse.unquote(reverse('horizon:admin:networks:subnets_tab',
+ args=[network_id]))
res = self.client.get(url)
redir_url = INDEX_URL
@@ -349,8 +349,8 @@ class NetworkTests(test.BaseAdminViewTests):
'network_availability_zone': True})
self.mock_tenant_quota_usages.return_value = quota_data
- url = urlunquote(reverse('horizon:admin:networks:subnets_tab',
- args=[network.id]))
+ url = parse.unquote(reverse('horizon:admin:networks:subnets_tab',
+ args=[network.id]))
res = self.client.get(url)
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
@@ -401,8 +401,8 @@ class NetworkTests(test.BaseAdminViewTests):
'dhcp_agent_scheduler': True})
self.mock_tenant_quota_usages.return_value = quota_data
- url = urlunquote(reverse('horizon:admin:networks:subnets_tab',
- args=[network.id]))
+ url = parse.unquote(reverse('horizon:admin:networks:subnets_tab',
+ args=[network.id]))
res = self.client.get(url)
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
diff --git a/openstack_dashboard/dashboards/admin/snapshots/tests.py b/openstack_dashboard/dashboards/admin/snapshots/tests.py
index c1f7b8cf7..e04a05e8b 100644
--- a/openstack_dashboard/dashboards/admin/snapshots/tests.py
+++ b/openstack_dashboard/dashboards/admin/snapshots/tests.py
@@ -11,11 +11,11 @@
# under the License.
from unittest import mock
+from urllib import parse
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.http import urlunquote
from openstack_dashboard.api import cinder
from openstack_dashboard.api import keystone
@@ -38,7 +38,7 @@ class VolumeSnapshotsViewTests(test.BaseAdminViewTests):
self.mock_tenant_list.return_value = [self.tenants.list(), False]
url = reverse(INDEX_URL)
- res = self.client.get(urlunquote(url))
+ res = self.client.get(parse.unquote(url))
self.assertEqual(res.status_code, 200)
self.assertTemplateUsed(res, 'horizon/common/_data_table_view.html')
@@ -63,7 +63,7 @@ class VolumeSnapshotsViewTests(test.BaseAdminViewTests):
self.mock_volume_list.return_value = self.cinder_volumes.list()
self.mock_tenant_list.return_value = [self.tenants.list(), False]
- res = self.client.get(urlunquote(url))
+ res = self.client.get(parse.unquote(url))
self.assertTemplateUsed(res, 'horizon/common/_data_table_view.html')
self.assertEqual(res.status_code, 200)
diff --git a/openstack_dashboard/dashboards/admin/volumes/tests.py b/openstack_dashboard/dashboards/admin/volumes/tests.py
index 29a39649b..37495cad9 100644
--- a/openstack_dashboard/dashboards/admin/volumes/tests.py
+++ b/openstack_dashboard/dashboards/admin/volumes/tests.py
@@ -13,11 +13,11 @@
# under the License.
import copy
+from urllib import parse
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.http import urlunquote
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.volumes \
@@ -92,7 +92,7 @@ class VolumeTests(test.BaseAdminViewTests):
self.mock_server_list.return_value = [self.servers.list(), False]
self.mock_tenant_list.return_value = [self.tenants.list(), False]
- res = self.client.get(urlunquote(url))
+ res = self.client.get(parse.unquote(url))
self.mock_server_list.assert_called_once_with(
test.IsHttpRequest(), search_opts={'all_tenants': True})
diff --git a/openstack_dashboard/dashboards/project/backups/tests.py b/openstack_dashboard/dashboards/project/backups/tests.py
index a3616fe0b..4a93d782a 100644
--- a/openstack_dashboard/dashboards/project/backups/tests.py
+++ b/openstack_dashboard/dashboards/project/backups/tests.py
@@ -10,11 +10,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from urllib import parse
+
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.http import urlencode
-from django.utils.http import urlunquote
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.backups \
@@ -39,7 +40,7 @@ class VolumeBackupsViewTests(test.TestCase):
self.mock_volume_snapshot_list.return_value \
= self.cinder_volume_snapshots.list()
- res = self.client.get(urlunquote(url))
+ res = self.client.get(parse.unquote(url))
self.assertEqual(res.status_code, 200)
self.assertTemplateUsed(res, 'horizon/common/_data_table_view.html')
diff --git a/openstack_dashboard/dashboards/project/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py
index 77dc74902..c6740589c 100644
--- a/openstack_dashboard/dashboards/project/networks/tests.py
+++ b/openstack_dashboard/dashboards/project/networks/tests.py
@@ -14,10 +14,10 @@
import collections
from unittest import mock
+from urllib import parse
from django.urls import reverse
from django.utils.html import escape
-from django.utils.http import urlunquote
from horizon.workflows import views
@@ -209,8 +209,8 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
self._stub_is_extension_supported({'mac-learning': mac_learning,
'network_availability_zone': True})
- url = urlunquote(reverse('horizon:project:networks:detail',
- args=[network_id]))
+ url = parse.unquote(reverse('horizon:project:networks:detail',
+ args=[network_id]))
res = self.client.get(url)
network = res.context['network']
@@ -243,8 +243,8 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
self._stub_is_extension_supported({'mac-learning': mac_learning,
'network_availability_zone': True})
- url = urlunquote(reverse('horizon:project:networks:subnets_tab',
- args=[network_id]))
+ url = parse.unquote(reverse('horizon:project:networks:subnets_tab',
+ args=[network_id]))
res = self.client.get(url)
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
@@ -313,8 +313,8 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
self._stub_is_extension_supported({'mac-learning': mac_learning,
'network_availability_zone': True})
- url = urlunquote(reverse('horizon:project:networks:subnets_tab',
- args=[network_id]))
+ url = parse.unquote(reverse('horizon:project:networks:subnets_tab',
+ args=[network_id]))
res = self.client.get(url)
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
@@ -354,8 +354,8 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
self._stub_is_extension_supported({'mac-learning': mac_learning,
'network_availability_zone': True})
- url = urlunquote(reverse('horizon:project:networks:subnets_tab',
- args=[network_id]))
+ url = parse.unquote(reverse('horizon:project:networks:subnets_tab',
+ args=[network_id]))
res = self.client.get(url)
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
subnets = res.context['subnets_table'].data
@@ -1263,8 +1263,8 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
'network_availability_zone': True})
self.mock_tenant_quota_usages.return_value = quota_data
- url = urlunquote(reverse('horizon:project:networks:subnets_tab',
- args=[network_id]))
+ url = parse.unquote(reverse('horizon:project:networks:subnets_tab',
+ args=[network_id]))
res = self.client.get(url)
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
@@ -1335,8 +1335,8 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
'network_availability_zone': True})
self.mock_tenant_quota_usages.return_value = quota_data
- url = urlunquote(reverse('horizon:project:networks:ports_tab',
- args=[network_id]))
+ url = parse.unquote(reverse('horizon:project:networks:ports_tab',
+ args=[network_id]))
res = self.client.get(url)
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
diff --git a/openstack_dashboard/dashboards/project/snapshots/tests.py b/openstack_dashboard/dashboards/project/snapshots/tests.py
index c2eec55de..56d723448 100644
--- a/openstack_dashboard/dashboards/project/snapshots/tests.py
+++ b/openstack_dashboard/dashboards/project/snapshots/tests.py
@@ -17,11 +17,11 @@
# under the License.
from unittest import mock
+from urllib import parse
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.http import urlunquote
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.snapshots \
@@ -49,7 +49,7 @@ class VolumeSnapshotsViewTests(test.TestCase):
self.mock_group_snapshot_list.return_value = \
self.cinder_volume_snapshots_with_groups.list()
- res = self.client.get(urlunquote(url))
+ res = self.client.get(parse.unquote(url))
self.assertEqual(res.status_code, 200)
self.assertTemplateUsed(res, 'horizon/common/_data_table_view.html')
diff --git a/openstack_dashboard/dashboards/project/volume_groups/tests.py b/openstack_dashboard/dashboards/project/volume_groups/tests.py
index d80b4fb42..4d7a8ef17 100644
--- a/openstack_dashboard/dashboards/project/volume_groups/tests.py
+++ b/openstack_dashboard/dashboards/project/volume_groups/tests.py
@@ -11,17 +11,17 @@
# under the License.
from unittest import mock
+from urllib import parse
from django.urls import reverse
-from django.utils.http import urlunquote
from openstack_dashboard.api import cinder
from openstack_dashboard.test import helpers as test
INDEX_URL = reverse('horizon:project:volume_groups:index')
-VOLUME_GROUPS_SNAP_INDEX_URL = urlunquote(reverse(
- 'horizon:project:vg_snapshots:index'))
+VOLUME_GROUPS_SNAP_INDEX_URL = parse.unquote(
+ reverse('horizon:project:vg_snapshots:index'))
class VolumeGroupTests(test.TestCase):
diff --git a/openstack_dashboard/dashboards/project/volumes/tests.py b/openstack_dashboard/dashboards/project/volumes/tests.py
index 37b39a41f..27ef73b5f 100644
--- a/openstack_dashboard/dashboards/project/volumes/tests.py
+++ b/openstack_dashboard/dashboards/project/volumes/tests.py
@@ -14,13 +14,13 @@
import copy
from unittest import mock
+from urllib import parse
from django.conf import settings
from django.forms import widgets
from django.template.defaultfilters import slugify
from django.test.utils import override_settings
from django.urls import reverse
-from django.utils.http import urlunquote
from openstack_dashboard import api
from openstack_dashboard.api import cinder
@@ -122,7 +122,7 @@ class VolumeIndexViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
self.mock_tenant_absolute_limits.return_value = \
self.cinder_limits['absolute']
- res = self.client.get(urlunquote(url))
+ res = self.client.get(parse.unquote(url))
self.assertEqual(2, self.mock_volume_backup_supported.call_count)
self.mock_volume_list_paged.assert_called_once_with(
diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py
index e9e644d83..5f0d72926 100644
--- a/openstack_dashboard/test/helpers.py
+++ b/openstack_dashboard/test/helpers.py
@@ -22,6 +22,7 @@ import logging
import os
import traceback
from unittest import mock
+from urllib import parse
from django.conf import settings
from django.contrib.messages.storage import cookie as cookie_storage
@@ -31,7 +32,6 @@ from django.test.client import RequestFactory
from django.test import tag
from django.test import testcases
from django import urls
-from django.utils import http
from openstack_auth import user
from openstack_auth import utils
@@ -289,8 +289,8 @@ class TestCase(horizon_helpers.TestCase):
loc = response['location']
else:
loc = ''
- loc = http.urlunquote(loc)
- expected_url = http.urlunquote(expected_url)
+ loc = parse.unquote(loc)
+ expected_url = parse.unquote(expected_url)
self.assertEqual(loc, expected_url)
self.assertEqual(response.status_code, 302)
diff --git a/openstack_dashboard/test/test_data/swift_data.py b/openstack_dashboard/test/test_data/swift_data.py
index 22c5bd17b..0b8e30976 100644
--- a/openstack_dashboard/test/test_data/swift_data.py
+++ b/openstack_dashboard/test/test_data/swift_data.py
@@ -11,9 +11,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_utils import timeutils
-from django.utils import http as utils_http
+from urllib import parse
+
+from oslo_utils import timeutils
from openstack_dashboard.api import swift
from openstack_dashboard.test.test_data import utils
@@ -45,8 +46,7 @@ def data(TEST):
"is_public": True,
"public_url":
"http://public.swift.example.com:8080/" +
- "v1/project_id/%s" % utils_http.urlquote(
- container_2_name)}
+ "v1/project_id/%s" % parse.quote(container_2_name)}
container_2 = swift.Container(container_dict_2)
container_dict_3 = {"name": "container,three%\u6346",
"container_object_count": 2,