py3: Replace unicode with six.text_type

Run the unicode operation of the sixer tool on openstack_dashboard/
directory.

tox.ini: Add the following tests to Python 3.4:

* openstack_dashboard.contrib.sahara.content.data_processing.data_sources.tests
* openstack_dashboard.contrib.sahara.content.data_processing.job_binaries.tests
* openstack_dashboard.contrib.sahara.content.data_processing.jobs.tests
* openstack_dashboard.dashboards.project.networks.tests

Partial-Implements: blueprint porting-python3
Change-Id: Ibfe52ccbccc30e6b1d59137c68942c9860805397
Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com>
This commit is contained in:
Victor Stinner 2015-10-06 15:22:19 +02:00
parent 71b4569a69
commit 1f29e5cd67
6 changed files with 23 additions and 22 deletions

View File

@ -106,10 +106,10 @@ class DataProcessingDataSourceTests(test.TestCase):
'description': data_source.description
}
api.sahara.data_source_get(IsA(http.HttpRequest),
IsA(unicode)) \
IsA(six.text_type)) \
.AndReturn(self.data_sources.first())
api.sahara.data_source_update(IsA(http.HttpRequest),
IsA(unicode),
IsA(six.text_type),
api_data) \
.AndReturn(self.data_sources.first())
self.mox.ReplayAll()

View File

@ -103,7 +103,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
@test.create_stubs({api.sahara: ('job_binary_get',
'job_binary_update')})
def test_update(self):
jb = api.sahara.job_binary_get(IsA(http.HttpRequest), IsA(unicode)) \
jb = api.sahara.job_binary_get(IsA(http.HttpRequest), IsA(six.text_type)) \
.AndReturn(self.job_binaries.first())
api.sahara.job_binary_update(IsA(http.HttpRequest),
IsA(str),

View File

@ -156,7 +156,7 @@ class DataProcessingJobTests(test.TestCase):
cluster = self.clusters.first()
input_ds = self.data_sources.first()
output_ds = self.data_sources.first()
api.sahara.job_get(IsA(http.HttpRequest), IsA(unicode)) \
api.sahara.job_get(IsA(http.HttpRequest), IsA(six.text_type)) \
.AndReturn(job)
api.sahara.job_get_configs(IsA(http.HttpRequest), job.type) \
.AndReturn(job)
@ -166,13 +166,13 @@ class DataProcessingJobTests(test.TestCase):
.MultipleTimes().AndReturn(self.data_sources.list())
api.sahara.job_list(IsA(http.HttpRequest)) \
.AndReturn(self.jobs.list())
api.sahara.job_get(IsA(http.HttpRequest), IsA(unicode)) \
api.sahara.job_get(IsA(http.HttpRequest), IsA(six.text_type)) \
.AndReturn(job)
api.sahara.job_execution_create(IsA(http.HttpRequest),
IsA(unicode),
IsA(unicode),
IsA(unicode),
IsA(unicode),
IsA(six.text_type),
IsA(six.text_type),
IsA(six.text_type),
IsA(six.text_type),
IsA(dict),
IsA(dict)).AndReturn(job_execution)
self.mox.ReplayAll()

View File

@ -24,6 +24,8 @@ from django.core.urlresolvers import reverse
from django.core.urlresolvers 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
@ -54,7 +56,8 @@ class IndexView(horizon_tables.DataTableView):
flavors = []
msg = _('Unable to retrieve database size information.')
exceptions.handle(self.request, msg)
return OrderedDict((unicode(flavor.id), flavor) for flavor in flavors)
return OrderedDict((six.text_type(flavor.id), flavor)
for flavor in flavors)
def _extra_data(self, cluster):
try:

View File

@ -16,8 +16,6 @@ from django.core.urlresolvers import reverse
from django import http
from django.utils.html import escape
import six
from horizon.workflows import views
from mox3.mox import IsA # noqa
@ -2194,8 +2192,7 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
url = create_link.get_link_url()
classes = (list(create_link.get_default_classes())
+ list(create_link.classes))
link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded")
link_name = "%s (%s)" % (create_link.verbose_name, "Quota exceeded")
expected_string = "<a href='%s' title='%s' class='%s disabled' "\
"id='networks__action_create'>" \
"<span class='fa fa-plus'></span>%s</a>" \
@ -2212,8 +2209,7 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
url = reverse(create_link.get_link_url(), args=[network_id])
classes = (list(create_link.get_default_classes())
+ list(create_link.classes))
link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded")
link_name = "%s (%s)" % (create_link.verbose_name, "Quota exceeded")
expected_string = "<a href='%s' class='%s disabled' " \
"id='networks__row_%s__action_subnet'>%s</a>" \
% (url, " ".join(classes), network_id, link_name)
@ -2229,11 +2225,11 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
url = create_link.get_link_url()
classes = (list(create_link.get_default_classes())
+ list(create_link.classes))
link_name = "%s" % (unicode(create_link.verbose_name),)
expected_string = "<a href='%s' title='%s' class='%s' "\
"id='networks__action_create'>" \
"<span class='fa fa-plus'></span>%s</a>" \
% (url, link_name, " ".join(classes), link_name)
% (url, create_link.verbose_name, " ".join(classes),
create_link.verbose_name)
self._test_create_button_shown_when_quota_disabled(expected_string)
@test.create_stubs({api.neutron: ('network_list',),
@ -2245,10 +2241,9 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
url = reverse(create_link.get_link_url(), args=[network_id])
classes = (list(create_link.get_default_classes())
+ list(create_link.classes))
link_name = "%s" % (unicode(create_link.verbose_name),)
expected_string = "<a href='%s' class='%s' "\
"id='networks__row_%s__action_subnet'>%s</a>" \
% (url, " ".join(classes), network_id, link_name)
% (url, " ".join(classes), network_id, create_link.verbose_name)
self._test_create_button_shown_when_quota_disabled(expected_string)
@test.create_stubs({api.neutron: ('network_get',
@ -2293,8 +2288,7 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
url = create_link.get_link_url()
classes = (list(create_link.get_default_classes())
+ list(create_link.classes))
link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded")
link_name = "%s (%s)" % (create_link.verbose_name, "Quota exceeded")
expected_string = "<a href='%s' title='%s' class='%s disabled' "\
"id='subnets__action_create'>" \
"<span class='fa fa-plus'></span>%s</a>" \

View File

@ -23,11 +23,15 @@ commands = /bin/bash run_tests.sh -N --no-pep8 {posargs}
commands =
python manage.py test --settings=horizon.test.settings horizon.test.tests
python manage.py test --settings=openstack_dashboard.test.settings \
openstack_dashboard.contrib.sahara.content.data_processing.data_sources.tests \
openstack_dashboard.contrib.sahara.content.data_processing.job_binaries.tests \
openstack_dashboard.contrib.sahara.content.data_processing.jobs.tests \
openstack_dashboard.dashboards.admin.volumes.volumes.tests \
openstack_dashboard.dashboards.identity.users \
openstack_dashboard.dashboards.project.access_and_security.api_access.tests \
openstack_dashboard.dashboards.project.images.images.tests.CreateImageFormTests \
openstack_dashboard.dashboards.project.images.tests.ImagesAndSnapshotsUtilsTests \
openstack_dashboard.dashboards.project.networks.tests \
openstack_dashboard.dashboards.project.overview.tests \
openstack_dashboard.dashboards.project.stacks.tests.TemplateFormTests \
openstack_dashboard.dashboards.settings.password \