Merge "Remove six usage"

This commit is contained in:
Zuul 2020-02-06 01:09:11 +00:00 committed by Gerrit Code Review
commit e03bad61e9
16 changed files with 102 additions and 145 deletions

View File

@ -15,7 +15,6 @@
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
import mock
import six
from openstack_auth import policy
from openstack_dashboard import api as dash_api
@ -150,7 +149,7 @@ class DatabasesBackupsTests(test.TestCase):
res = self.client.get(DETAILS_URL)
self.mock_backup_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str))
self.assertTemplateUsed(res,
@ -162,7 +161,7 @@ class DatabasesBackupsTests(test.TestCase):
res = self.client.get(DETAILS_URL)
self.mock_backup_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_mocks({api.trove: ('backup_get', 'instance_get')})
@ -177,7 +176,7 @@ class DatabasesBackupsTests(test.TestCase):
args=[incr_backup.id])
res = self.client.get(url)
self.assertEqual(
[mock.call(test.IsHttpRequest(), test.IsA(six.text_type)),
[mock.call(test.IsHttpRequest(), test.IsA(str)),
mock.call(test.IsHttpRequest(), incr_backup.parent_id)],
self.mock_backup_get.call_args_list)
self.mock_instance_get.assert_called_once_with(
@ -216,13 +215,12 @@ class DatabasesBackupsTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_check, 4, mock.call((), test.IsHttpRequest()))
self.mock_backup_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_configuration_list.assert_called_once_with(
test.IsHttpRequest())
self.mock_datastore_flavors.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.string_types),
test.IsA(six.string_types))
test.IsHttpRequest(), test.IsA(str), test.IsA(str))
self.mock_datastore_list.assert_called_once_with(test.IsHttpRequest())
self.mock_datastore_version_list.assert_called_once_with(
test.IsHttpRequest(), backup.datastore['type'])

View File

@ -20,8 +20,6 @@ from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.debug import sensitive_variables # noqa
import six
from horizon import exceptions
from horizon import forms
from horizon import messages
@ -376,8 +374,7 @@ class LaunchForm(forms.SelfHandlingForm):
except Exception as e:
redirect = reverse("horizon:project:database_clusters:index")
exceptions.handle(request,
_('Unable to launch cluster. %s') %
six.text_type(e),
_('Unable to launch cluster. %s') % e,
redirect=redirect)
@ -479,8 +476,7 @@ class ClusterAddInstanceForm(forms.SelfHandlingForm):
except Exception as e:
redirect = reverse("horizon:project:database_clusters:index")
exceptions.handle(request,
_('Unable to grow cluster. %s') %
six.text_type(e),
_('Unable to grow cluster. %s') % e,
redirect=redirect)
return True
@ -503,6 +499,6 @@ class ResetPasswordForm(forms.SelfHandlingForm):
'cluster "%s"') % cluster_id)
except Exception as e:
redirect = reverse("horizon:project:database_clusters:index")
exceptions.handle(request, _('Unable to reset password. %s') %
six.text_type(e), redirect=redirect)
exceptions.handle(request, _('Unable to reset password. %s') % e,
redirect=redirect)
return True

View File

@ -20,8 +20,6 @@ from django import urls
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
import six
from horizon import messages
from horizon import tables
from horizon.templatetags import sizeformat
@ -280,10 +278,10 @@ class ClusterShrinkAction(tables.BatchAction):
except Exception as ex:
LOG.error('Action %(action)s failed with %(ex)s for %(data)s' %
{'action': self._get_action_name(past=True).lower(),
'ex': six.text_type(ex),
'ex': ex,
'data': display_str})
msg = _('Unable to remove instances from cluster: %s')
messages.error(request, msg % six.text_type(ex))
messages.error(request, msg % ex)
return shortcuts.redirect(self.get_success_url(request))
@ -415,10 +413,10 @@ class ClusterGrowAction(tables.Action):
messages.success(request, msg)
except Exception as ex:
LOG.error('Action grow cluster failed with %(ex)s for %(data)s' %
{'ex': six.text_type(ex),
{'ex': ex,
'data': display_str})
msg = _('Unable to grow cluster: %s')
messages.error(request, msg % six.text_type(ex))
messages.error(request, msg % ex)
finally:
cluster_manager.delete(cluster_id)

View File

@ -23,8 +23,6 @@ from django.urls import reverse
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions
from horizon import forms as horizon_forms
from horizon import tables as horizon_tables
@ -58,7 +56,7 @@ class IndexView(horizon_tables.DataTableView):
flavors = []
msg = _('Unable to retrieve database size information.')
exceptions.handle(self.request, msg)
return OrderedDict((six.text_type(flavor.id), flavor)
return OrderedDict((str(flavor.id), flavor)
for flavor in flavors)
def _extra_data(self, cluster):

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import builtins
from django.core import cache
from django.utils.translation import ugettext_lazy as _
@ -19,7 +20,6 @@ from django.utils.translation import ugettext_lazy as _
from trove_dashboard import api
from oslo_serialization import jsonutils
from six.moves import builtins
def get(request, configuration_group_id):

View File

@ -15,8 +15,6 @@
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions
from horizon import forms
from horizon import messages
@ -108,8 +106,7 @@ class CreateConfigurationForm(forms.SelfHandlingForm):
except Exception as e:
redirect = reverse("horizon:project:database_configurations:index")
exceptions.handle(request, _('Unable to create configuration '
'group. %s')
% six.text_type(e), redirect=redirect)
'group. %s') % e, redirect=redirect)
return True
@ -186,6 +183,7 @@ class AddParameterForm(forms.SelfHandlingForm):
messages.success(request, _('Successfully added parameter'))
except Exception as e:
redirect = reverse("horizon:project:database_configurations:index")
exceptions.handle(request, _('Unable to add new parameter: %s')
% six.text_type(e), redirect=redirect)
exceptions.handle(request,
_('Unable to add new parameter: %s') % e,
redirect=redirect)
return True

View File

@ -17,8 +17,6 @@ from django import urls
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
import six
from horizon import forms
from horizon import messages
from horizon import tables
@ -139,7 +137,7 @@ class DiscardChanges(tables.Action):
except Exception as ex:
messages.error(
request,
_('Error resetting parameters: %s') % six.text_type(ex))
_('Error resetting parameters: %s') % ex)
return shortcuts.redirect(request.build_absolute_uri())

View File

@ -14,7 +14,6 @@
import logging
import mock
import six
import django
from django.conf import settings
@ -338,12 +337,10 @@ class DatabaseConfigurationsTests(test.TestCase):
post)
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_get, 2,
mock.call(test.IsHttpRequest(), test.IsA(six.string_types)))
mock.call(test.IsHttpRequest(), test.IsA(str)))
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_configuration_parameters_list, 2,
mock.call(test.IsHttpRequest(),
test.IsA(six.string_types),
test.IsA(six.string_types)))
mock.call(test.IsHttpRequest(), test.IsA(str), test.IsA(str)))
self.assertFormError(res, "form", 'value',
['Value must be a number.'])
finally:

View File

@ -16,8 +16,6 @@ from django.forms import ValidationError # noqa
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions
from horizon import forms
from horizon import messages
@ -48,8 +46,8 @@ class CreateDatabaseForm(forms.SelfHandlingForm):
except Exception as e:
redirect = reverse("horizon:project:databases:detail",
args=(instance,))
exceptions.handle(request, _('Unable to create database. %s') %
six.text_type(e), redirect=redirect)
exceptions.handle(request, _('Unable to create database. %s') % e,
redirect=redirect)
return True
@ -89,8 +87,8 @@ class ResizeVolumeForm(forms.SelfHandlingForm):
messages.success(request, _('Resizing volume "%s"') % instance)
except Exception as e:
redirect = reverse("horizon:project:databases:index")
exceptions.handle(request, _('Unable to resize volume. %s') %
six.text_type(e), redirect=redirect)
exceptions.handle(request, _('Unable to resize volume. %s') % e,
redirect=redirect)
return True
@ -127,8 +125,8 @@ class ResizeInstanceForm(forms.SelfHandlingForm):
messages.success(request, _('Resizing instance "%s"') % instance)
except Exception as e:
redirect = reverse("horizon:project:databases:index")
exceptions.handle(request, _('Unable to resize instance. %s') %
six.text_type(e), redirect=redirect)
exceptions.handle(request, _('Unable to resize instance. %s') % e,
redirect=redirect)
return True
@ -148,7 +146,7 @@ class PromoteToReplicaSourceForm(forms.SelfHandlingForm):
exceptions.handle(
request,
_('Unable to promote replica as the new replica source. "%s"')
% six.text_type(e), redirect=redirect)
% e, redirect=redirect)
return True
@ -183,8 +181,8 @@ class CreateUserForm(forms.SelfHandlingForm):
except Exception as e:
redirect = reverse("horizon:project:databases:detail",
args=(instance,))
exceptions.handle(request, _('Unable to create user. %s') %
six.text_type(e), redirect=redirect)
exceptions.handle(request, _('Unable to create user. %s') % e,
redirect=redirect)
return True
def _get_databases(self, data):
@ -232,8 +230,8 @@ class EditUserForm(forms.SelfHandlingForm):
except Exception as e:
redirect = reverse("horizon:project:databases:detail",
args=(instance,))
exceptions.handle(request, _('Unable to update user. %s') %
six.text_type(e), redirect=redirect)
exceptions.handle(request, _('Unable to update user. %s') % e,
redirect=redirect)
return True
def clean(self):
@ -280,6 +278,6 @@ class AttachConfigurationForm(forms.SelfHandlingForm):
except Exception as e:
redirect = reverse("horizon:project:databases:index")
exceptions.handle(request, _('Unable to attach configuration '
'group. %s')
% six.text_type(e), redirect=redirect)
'group. %s') % e,
redirect=redirect)
return True

View File

@ -18,7 +18,6 @@ from django import http
from django.urls import reverse
import mock
import six
from trove_dashboard import api
from trove_dashboard.test import helpers as test
@ -45,7 +44,7 @@ class LogsTests(test.TestCase):
url = detail_url + '?tab=instance_details__logs_tab'
res = self.client.get(url)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -83,7 +82,7 @@ class LogsTests(test.TestCase):
try:
res = self.client.get(url)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -118,7 +117,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string}
res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -146,7 +145,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string}
res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -174,7 +173,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string}
res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -202,7 +201,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string}
res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -230,7 +229,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string}
res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -258,7 +257,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string}
res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -286,7 +285,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string}
res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -314,7 +313,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string}
res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with(
@ -346,7 +345,7 @@ class LogsTests(test.TestCase):
auth_version="3")
self.mock_log_tail.assert_called_once_with(
test.IsHttpRequest(),
test.IsA(six.string_types),
test.IsA(str),
'guest.log',
False,
LINES,
@ -377,7 +376,7 @@ class LogsTests(test.TestCase):
auth_version="3")
self.mock_log_tail.assert_called_once_with(
test.IsHttpRequest(),
test.IsA(six.string_types),
test.IsA(str),
'guest.log',
False,
LINES,

View File

@ -17,8 +17,6 @@ from django import shortcuts
from django.utils.translation import ugettext_lazy as _
from django.views import generic
import six
from horizon import exceptions
from horizon import messages
@ -65,8 +63,7 @@ def get_contents(request, instance_id, filename, publish, lines):
for log_part in log_generator():
data += log_part
except Exception as e:
data = _('Unable to load {0} log\n{1}').format(filename,
six.text_type(e))
data = _('Unable to load {0} log\n{1}').format(filename, e)
return data

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from urllib import parse as urlparse
from django.conf import settings
from django.template import defaultfilters as d_filters
from django import urls
@ -20,9 +22,6 @@ from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
import six
import six.moves.urllib.parse as urlparse
from horizon import exceptions
from horizon import messages
from horizon import tables
@ -511,8 +510,7 @@ class DisableRootAction(tables.Action):
messages.success(request, _("Successfully disabled root access."))
except Exception as e:
messages.warning(request,
_("Cannot disable root access: %s") %
six.text_type(e))
_("Cannot disable root access: %s") % e)
class ManageRoot(tables.LinkAction):

View File

@ -15,8 +15,6 @@
from django import template
from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions
from horizon import tabs
from oslo_log import log as logging
@ -180,7 +178,7 @@ class LogsTab(tabs.TableTab):
return logs
except Exception as e:
LOG.exception(
_('Unable to retrieve list of logs.\n%s') % six.text_type(e))
_('Unable to retrieve list of logs.\n%s') % e)
logs = []
return logs

View File

@ -21,7 +21,6 @@ from django.urls import reverse
import unittest
import mock
import six
from horizon import exceptions
from openstack_auth import policy
@ -158,8 +157,8 @@ class DatabaseTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_datastore_flavors, 20,
mock.call(test.IsHttpRequest(),
test.IsA(six.string_types),
test.IsA(six.string_types)))
test.IsA(str),
test.IsA(str)))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_configuration_list.assert_called_once_with(
test.IsHttpRequest())
@ -264,8 +263,8 @@ class DatabaseTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_datastore_flavors, 20,
mock.call(test.IsHttpRequest(),
test.IsA(six.string_types),
test.IsA(six.string_types)))
test.IsA(str),
test.IsA(str)))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_instance_list.assert_called_once_with(test.IsHttpRequest())
self.mock_datastore_list.assert_called_once_with(test.IsHttpRequest())
@ -283,9 +282,9 @@ class DatabaseTests(test.TestCase):
test.IsHttpRequest())
self.mock_instance_create.assert_called_once_with(
test.IsHttpRequest(),
test.IsA(six.text_type),
test.IsA(str),
test.IsA(int),
test.IsA(six.text_type),
test.IsA(str),
databases=None,
datastore=datastore,
datastore_version=datastore_version,
@ -297,7 +296,7 @@ class DatabaseTests(test.TestCase):
replica_count=None,
volume_type=None,
locality=None,
availability_zone=test.IsA(six.text_type))
availability_zone=test.IsA(str))
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_mocks({
@ -354,8 +353,8 @@ class DatabaseTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_datastore_flavors, 20,
mock.call(test.IsHttpRequest(),
test.IsA(six.string_types),
test.IsA(six.string_types)))
test.IsA(str),
test.IsA(str)))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_instance_list.assert_called_once_with(test.IsHttpRequest())
self.mock_datastore_list.assert_called_once_with(test.IsHttpRequest())
@ -373,9 +372,9 @@ class DatabaseTests(test.TestCase):
test.IsHttpRequest())
self.mock_instance_create.assert_called_once_with(
test.IsHttpRequest(),
test.IsA(six.text_type),
test.IsA(str),
test.IsA(int),
test.IsA(six.text_type),
test.IsA(str),
databases=None,
datastore=datastore,
datastore_version=datastore_version,
@ -387,7 +386,7 @@ class DatabaseTests(test.TestCase):
replica_count=None,
volume_type=None,
locality=None,
availability_zone=test.IsA(six.text_type))
availability_zone=test.IsA(str))
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_mocks({
@ -409,7 +408,7 @@ class DatabaseTests(test.TestCase):
try:
res = self.client.get(DETAILS_URL)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_flavor_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str))
self.mock_root_show.assert_called_once_with(
@ -521,7 +520,7 @@ class DatabaseTests(test.TestCase):
args=['id'])
res = self.client.get(url)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_root_show, 2,
mock.call(test.IsHttpRequest(), database.id))
@ -539,7 +538,7 @@ class DatabaseTests(test.TestCase):
args=['id'])
res = self.client.get(url)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_root_show.assert_called_once_with(
test.IsHttpRequest(), u'id')
self.assertRedirectsNoFollow(res, DETAILS_URL)
@ -667,7 +666,7 @@ class DatabaseTests(test.TestCase):
form_data = {'action': action_string}
res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_flavor_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str))
self.mock_users_list.assert_called_once_with(
@ -752,11 +751,11 @@ class DatabaseTests(test.TestCase):
res = self.client.post(url, post)
self.mock_user_update_attributes.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type),
test.IsA(six.text_type), host=test.IsA(six.text_type),
new_name=test.IsA(six.text_type),
new_password=test.IsA(six.text_type),
new_host=test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str),
test.IsA(str), host=test.IsA(str),
new_name=test.IsA(str),
new_password=test.IsA(str),
new_host=test.IsA(str))
self.assertNoFormErrors(res)
self.assertMessageCount(success=1)
@ -778,11 +777,11 @@ class DatabaseTests(test.TestCase):
res = self.client.post(url, post)
self.mock_user_update_attributes.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type),
test.IsA(six.text_type), host=test.IsA(six.text_type),
new_name=test.IsA(six.text_type),
new_password=test.IsA(six.text_type),
new_host=test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str),
test.IsA(str), host=test.IsA(str),
new_name=test.IsA(str),
new_password=test.IsA(str),
new_host=test.IsA(str))
self.assertEqual(res.status_code, 302)
def test_edit_user_no_values(self):
@ -810,10 +809,10 @@ class DatabaseTests(test.TestCase):
args=['id', 'name', 'host'])
res = self.client.get(url)
self.mock_database_list.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_user_show_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type),
test.IsA(six.text_type), host=test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str),
test.IsA(str), host=test.IsA(str))
self.assertTemplateUsed(
res, 'project/databases/access_detail.html')
@ -826,10 +825,10 @@ class DatabaseTests(test.TestCase):
args=['id', 'name', 'host'])
res = self.client.get(url)
self.mock_database_list.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_user_show_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type),
test.IsA(six.text_type), host=test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str),
test.IsA(str), host=test.IsA(str))
self.assertRedirectsNoFollow(res, DETAILS_URL)
@test.create_mocks({api.trove: ('user_grant_access',)})
@ -850,7 +849,7 @@ class DatabaseTests(test.TestCase):
self.mock_user_grant_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str), test.IsA(str),
[test.IsA(six.text_type)], host=test.IsA(str))
[test.IsA(str)], host=test.IsA(str))
handled_url = handled['location']
self.assertEqual(handled_url, url)
@ -874,7 +873,7 @@ class DatabaseTests(test.TestCase):
self.mock_user_grant_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str), test.IsA(str),
[test.IsA(six.text_type)], host=test.IsA(str))
[test.IsA(str)], host=test.IsA(str))
handled_url = handled['location']
self.assertEqual(handled_url, url)
@ -896,7 +895,7 @@ class DatabaseTests(test.TestCase):
self.mock_user_revoke_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str), test.IsA(str),
test.IsA(six.text_type), host=test.IsA(str))
test.IsA(str), host=test.IsA(str))
handled_url = handled['location']
self.assertEqual(handled_url, url)
@ -920,7 +919,7 @@ class DatabaseTests(test.TestCase):
self.mock_user_revoke_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str), test.IsA(str),
test.IsA(six.text_type), host=test.IsA(str))
test.IsA(str), host=test.IsA(str))
handled_url = handled['location']
self.assertEqual(handled_url, url)
@ -946,7 +945,7 @@ class DatabaseTests(test.TestCase):
}
res = self.client.post(url, post)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_instance_resize_volume.assert_called_once_with(
test.IsHttpRequest(), database_id, test.IsA(int))
self.assertNoFormErrors(res)
@ -970,7 +969,7 @@ class DatabaseTests(test.TestCase):
}
res = self.client.post(url, post)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.assertContains(
res, "New size for volume must be greater than current size.")
@ -1088,8 +1087,8 @@ class DatabaseTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_datastore_flavors, 20,
mock.call(test.IsHttpRequest(),
test.IsA(six.string_types),
test.IsA(six.string_types)))
test.IsA(str),
test.IsA(str)))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_instance_list_all.assert_called_once_with(
test.IsHttpRequest())
@ -1107,12 +1106,12 @@ class DatabaseTests(test.TestCase):
self.mock_availability_zone_list.assert_called_once_with(
test.IsHttpRequest())
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_instance_create.assert_called_once_with(
test.IsHttpRequest(),
test.IsA(six.text_type),
test.IsA(str),
test.IsA(int),
test.IsA(six.text_type),
test.IsA(str),
databases=None,
datastore=datastore,
datastore_version=datastore_version,
@ -1124,7 +1123,7 @@ class DatabaseTests(test.TestCase):
replica_count=2,
volume_type=None,
locality=None,
availability_zone=test.IsA(six.text_type))
availability_zone=test.IsA(str))
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_mocks({
@ -1278,7 +1277,7 @@ class DatabaseTests(test.TestCase):
}
res = self.client.post(url, form)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_configuration_list.assert_called_once_with(
test.IsHttpRequest())
self.mock_instance_attach_configuration.assert_called_once_with(
@ -1309,7 +1308,7 @@ class DatabaseTests(test.TestCase):
}
res = self.client.post(url, form)
self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type))
test.IsHttpRequest(), test.IsA(str))
self.mock_configuration_list.assert_called_once_with(
test.IsHttpRequest())
self.mock_instance_attach_configuration.assert_called_once_with(

View File

@ -21,8 +21,6 @@ from django.urls import reverse
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions
from horizon import forms as horizon_forms
from horizon import tables as horizon_tables
@ -58,7 +56,7 @@ class IndexView(horizon_tables.DataTableView):
flavors = []
msg = _('Unable to retrieve database size information.')
exceptions.handle(self.request, msg)
return OrderedDict((six.text_type(flavor.id), flavor)
return OrderedDict((str(flavor.id), flavor)
for flavor in flavors)
def _extra_data(self, instance):

View File

@ -12,27 +12,14 @@
# under the License.
import binascii
import six
def hexlify(text):
"""Hexlify raw text, return hexlified text."""
if six.PY3:
text = text.encode('utf-8')
hexlified = binascii.hexlify(text)
if six.PY3:
hexlified = hexlified.decode('utf-8')
return hexlified
text = text.encode('utf-8')
return binascii.hexlify(text).decode('utf-8')
def unhexlify(text):
"""Unhexlify raw text, return unhexlified text."""
unhexlified = binascii.unhexlify(text)
if six.PY3:
unhexlified = unhexlified.decode('utf-8')
return unhexlified
return binascii.unhexlify(text).decode('utf-8')