Merge "py3: Replace unicode with six.text_type"

This commit is contained in:
Jenkins 2015-08-28 02:10:33 +00:00 committed by Gerrit Code Review
commit 7cfbb416e4
36 changed files with 131 additions and 84 deletions

View File

@ -40,7 +40,7 @@ class FormsetCell(horizon_tables.Cell):
self.attrs['class'] = (self.attrs.get('class', '') + self.attrs['class'] = (self.attrs.get('class', '') +
' error form-group') ' error form-group')
self.attrs['title'] = ' '.join( self.attrs['title'] = ' '.join(
unicode(error) for error in self.field.errors) six.text_type(error) for error in self.field.errors)
class FormsetRow(horizon_tables.Row): class FormsetRow(horizon_tables.Row):

View File

@ -263,7 +263,7 @@ class Tab(html.HTMLElement):
# Priority: constructor, class-defined, fallback # Priority: constructor, class-defined, fallback
if not self.name: if not self.name:
raise ValueError("%s must have a name." % self.__class__.__name__) raise ValueError("%s must have a name." % self.__class__.__name__)
self.name = unicode(self.name) # Force unicode. self.name = six.text_type(self.name) # Force unicode.
if not self.slug: if not self.slug:
raise ValueError("%s must have a slug." % self.__class__.__name__) raise ValueError("%s must have a slug." % self.__class__.__name__)
self.tab_group = tab_group self.tab_group = tab_group

View File

@ -24,6 +24,8 @@ from django.core import urlresolvers
from django.utils.importlib import import_module # noqa from django.utils.importlib import import_module # noqa
from six import moves from six import moves
import six
import horizon import horizon
from horizon import base from horizon import base
from horizon import conf from horizon import conf
@ -163,7 +165,7 @@ class HorizonTests(BaseHorizonTests):
horizon.get_dashboard(MyDash) horizon.get_dashboard(MyDash)
def test_site(self): def test_site(self):
self.assertEqual("Horizon", unicode(base.Horizon)) self.assertEqual("Horizon", six.text_type(base.Horizon))
self.assertEqual("<Site: horizon>", repr(base.Horizon)) self.assertEqual("<Site: horizon>", repr(base.Horizon))
dash = base.Horizon.get_dashboard('cats') dash = base.Horizon.get_dashboard('cats')
self.assertEqual(dash, base.Horizon.get_default_dashboard()) self.assertEqual(dash, base.Horizon.get_default_dashboard())

View File

@ -20,6 +20,7 @@ from django import shortcuts
from django.template import defaultfilters from django.template import defaultfilters
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from horizon import tables from horizon import tables
from horizon.tables import formset as table_formset from horizon.tables import formset as table_formset
@ -331,7 +332,7 @@ class DataTableTests(test.TestCase):
self.assertTrue(self.table._meta.actions_column) self.assertTrue(self.table._meta.actions_column)
self.assertTrue(self.table._meta.multi_select) self.assertTrue(self.table._meta.multi_select)
# Test for verbose_name # Test for verbose_name
self.assertEqual(u"My Table", unicode(self.table)) self.assertEqual(u"My Table", six.text_type(self.table))
# Column ordering and exclusion. # Column ordering and exclusion.
# This should include auto-columns for multi_select and actions, # This should include auto-columns for multi_select and actions,
# but should not contain the excluded column. # but should not contain the excluded column.
@ -497,8 +498,8 @@ class DataTableTests(test.TestCase):
self.assertEqual('1', row.cells['id'].data) # Standard attr access self.assertEqual('1', row.cells['id'].data) # Standard attr access
self.assertEqual('custom object_1', row.cells['name'].data) # Callable self.assertEqual('custom object_1', row.cells['name'].data) # Callable
# name and verbose_name # name and verbose_name
self.assertEqual("Id", unicode(id_col)) self.assertEqual("Id", six.text_type(id_col))
self.assertEqual("Verbose Name", unicode(name_col)) self.assertEqual("Verbose Name", six.text_type(name_col))
# sortable # sortable
self.assertEqual(False, id_col.sortable) self.assertEqual(False, id_col.sortable)
self.assertNotIn("sortable", id_col.get_final_attrs().get('class', "")) self.assertNotIn("sortable", id_col.get_final_attrs().get('class', ""))
@ -862,13 +863,15 @@ class DataTableTests(test.TestCase):
req = self.factory.get('/my_url/') req = self.factory.get('/my_url/')
self.table = MyTable(req, TEST_DATA_3) self.table = MyTable(req, TEST_DATA_3)
toggle_action = self.table.get_row_actions(TEST_DATA_3[0])[2] toggle_action = self.table.get_row_actions(TEST_DATA_3[0])[2]
self.assertEqual("Batch Item", unicode(toggle_action.verbose_name)) self.assertEqual("Batch Item",
six.text_type(toggle_action.verbose_name))
# Batch action with custom help text # Batch action with custom help text
req = self.factory.get('/my_url/') req = self.factory.get('/my_url/')
self.table = MyTable(req, TEST_DATA_3) self.table = MyTable(req, TEST_DATA_3)
toggle_action = self.table.get_row_actions(TEST_DATA_3[0])[4] toggle_action = self.table.get_row_actions(TEST_DATA_3[0])[4]
self.assertEqual("BatchHelp Item", unicode(toggle_action.verbose_name)) self.assertEqual("BatchHelp Item",
six.text_type(toggle_action.verbose_name))
# Single object toggle action # Single object toggle action
# GET page - 'up' to 'down' # GET page - 'up' to 'down'
@ -876,7 +879,8 @@ class DataTableTests(test.TestCase):
self.table = MyTable(req, TEST_DATA_3) self.table = MyTable(req, TEST_DATA_3)
self.assertEqual(5, len(self.table.get_row_actions(TEST_DATA_3[0]))) self.assertEqual(5, len(self.table.get_row_actions(TEST_DATA_3[0])))
toggle_action = self.table.get_row_actions(TEST_DATA_3[0])[3] toggle_action = self.table.get_row_actions(TEST_DATA_3[0])[3]
self.assertEqual("Down Item", unicode(toggle_action.verbose_name)) self.assertEqual("Down Item",
six.text_type(toggle_action.verbose_name))
# Toggle from status 'up' to 'down' # Toggle from status 'up' to 'down'
# POST page # POST page
@ -897,7 +901,7 @@ class DataTableTests(test.TestCase):
self.table = MyTable(req, TEST_DATA_2) self.table = MyTable(req, TEST_DATA_2)
self.assertEqual(4, len(self.table.get_row_actions(TEST_DATA_2[0]))) self.assertEqual(4, len(self.table.get_row_actions(TEST_DATA_2[0])))
toggle_action = self.table.get_row_actions(TEST_DATA_2[0])[2] toggle_action = self.table.get_row_actions(TEST_DATA_2[0])[2]
self.assertEqual("Up Item", unicode(toggle_action.verbose_name)) self.assertEqual("Up Item", six.text_type(toggle_action.verbose_name))
# POST page # POST page
action_string = "my_table__toggle__2" action_string = "my_table__toggle__2"
@ -1013,12 +1017,16 @@ class DataTableTests(test.TestCase):
# Verbose names # Verbose names
table_actions = self.table.get_table_actions() table_actions = self.table.get_table_actions()
self.assertEqual("Filter", unicode(table_actions[0].verbose_name)) self.assertEqual("Filter",
self.assertEqual("Delete Me", unicode(table_actions[1].verbose_name)) six.text_type(table_actions[0].verbose_name))
self.assertEqual("Delete Me",
six.text_type(table_actions[1].verbose_name))
row_actions = self.table.get_row_actions(TEST_DATA[0]) row_actions = self.table.get_row_actions(TEST_DATA[0])
self.assertEqual("Delete Me", unicode(row_actions[0].verbose_name)) self.assertEqual("Delete Me",
self.assertEqual("Log In", unicode(row_actions[1].verbose_name)) six.text_type(row_actions[0].verbose_name))
self.assertEqual("Log In",
six.text_type(row_actions[1].verbose_name))
def test_server_filtering(self): def test_server_filtering(self):
filter_value_param = "my_table__filter__q" filter_value_param = "my_table__filter__q"
@ -1266,8 +1274,8 @@ class DataTableTests(test.TestCase):
self.assertEqual('1', row.cells['id'].data) # Standard attr access self.assertEqual('1', row.cells['id'].data) # Standard attr access
self.assertEqual('custom object_1', row.cells['name'].data) # Callable self.assertEqual('custom object_1', row.cells['name'].data) # Callable
# name and verbose_name # name and verbose_name
self.assertEqual("Id", unicode(id_col)) self.assertEqual("Id", six.text_type(id_col))
self.assertEqual("Verbose Name", unicode(name_col)) self.assertEqual("Verbose Name", six.text_type(name_col))
self.assertIn("sortable", name_col.get_final_attrs().get('class', "")) self.assertIn("sortable", name_col.get_final_attrs().get('class', ""))
# hidden # hidden
self.assertEqual(True, id_col.hidden) self.assertEqual(True, id_col.hidden)

View File

@ -15,6 +15,8 @@
from django import forms from django import forms
from django import http from django import http
import six
from horizon import exceptions from horizon import exceptions
from horizon.test import helpers as test from horizon.test import helpers as test
from horizon import workflows from horizon import workflows
@ -267,10 +269,10 @@ class WorkflowsTests(test.TestCase):
req = self.factory.get("/foo") req = self.factory.get("/foo")
flow = TestWorkflow(req) flow = TestWorkflow(req)
output = http.HttpResponse(flow.render()) output = http.HttpResponse(flow.render())
self.assertContains(output, unicode(flow.name)) self.assertContains(output, six.text_type(flow.name))
self.assertContains(output, unicode(TestActionOne.name)) self.assertContains(output, six.text_type(TestActionOne.name))
self.assertContains(output, unicode(TestActionTwo.name)) self.assertContains(output, six.text_type(TestActionTwo.name))
self.assertContains(output, unicode(TestActionThree.name)) self.assertContains(output, six.text_type(TestActionThree.name))
def test_has_permissions(self): def test_has_permissions(self):
self.assertQuerysetEqual(TestWorkflow._cls_registry, []) self.assertQuerysetEqual(TestWorkflow._cls_registry, [])

View File

@ -154,7 +154,7 @@ class WorkflowView(hz_views.ModalBackdropMixin, generic.TemplateView):
for step in workflow.steps[start:end + 1]: for step in workflow.steps[start:end + 1]:
if not step.action.is_valid(): if not step.action.is_valid():
errors[step.slug] = dict( errors[step.slug] = dict(
(field, [unicode(error) for error in errors]) (field, [six.text_type(error) for error in errors])
for (field, errors) in six.iteritems(step.action.errors)) for (field, errors) in six.iteritems(step.action.errors))
return { return {
'has_errors': bool(errors), 'has_errors': bool(errors),

View File

@ -102,7 +102,7 @@ class Service(base.APIDictWrapper):
return self.type return self.type
def __repr__(self): def __repr__(self):
return "<Service: %s>" % unicode(self) return "<Service: %s>" % six.text_type(self)
def _get_endpoint_url(request, endpoint_type, catalog=None): def _get_endpoint_url(request, endpoint_type, catalog=None):

View File

@ -18,6 +18,7 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard import api as dash_api from openstack_dashboard import api as dash_api
from openstack_dashboard.contrib.sahara import api from openstack_dashboard.contrib.sahara import api
@ -50,7 +51,7 @@ class DataProcessingClusterTemplateTests(test.TestCase):
dash_api.nova.flavor_get(IsA(http.HttpRequest), flavor.id) \ dash_api.nova.flavor_get(IsA(http.HttpRequest), flavor.id) \
.MultipleTimes().AndReturn(flavor) .MultipleTimes().AndReturn(flavor)
api.sahara.cluster_template_get(IsA(http.HttpRequest), api.sahara.cluster_template_get(IsA(http.HttpRequest),
IsA(unicode)) \ IsA(six.text_type)) \
.MultipleTimes().AndReturn(ct) .MultipleTimes().AndReturn(ct)
self.mox.ReplayAll() self.mox.ReplayAll()
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)

View File

@ -14,6 +14,7 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard.contrib.sahara import api from openstack_dashboard.contrib.sahara import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -39,7 +40,7 @@ class DataProcessingPluginsTests(test.TestCase):
@test.create_stubs({api.sahara: ('plugin_get',)}) @test.create_stubs({api.sahara: ('plugin_get',)})
def test_details(self): def test_details(self):
api.sahara.plugin_get(IsA(http.HttpRequest), IsA(unicode)) \ api.sahara.plugin_get(IsA(http.HttpRequest), IsA(six.text_type)) \
.AndReturn(self.plugins.list()[0]) .AndReturn(self.plugins.list()[0])
self.mox.ReplayAll() self.mox.ReplayAll()
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)

View File

@ -14,6 +14,7 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard.contrib.sahara import api from openstack_dashboard.contrib.sahara import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -45,7 +46,7 @@ class DataProcessingDataSourceTests(test.TestCase):
@test.create_stubs({api.sahara: ('data_source_get',)}) @test.create_stubs({api.sahara: ('data_source_get',)})
def test_details(self): def test_details(self):
api.sahara.data_source_get(IsA(http.HttpRequest), IsA(unicode)) \ api.sahara.data_source_get(IsA(http.HttpRequest), IsA(six.text_type)) \
.MultipleTimes().AndReturn(self.data_sources.first()) .MultipleTimes().AndReturn(self.data_sources.first())
self.mox.ReplayAll() self.mox.ReplayAll()
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)

View File

@ -14,6 +14,7 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard.contrib.sahara import api from openstack_dashboard.contrib.sahara import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -39,7 +40,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
@test.create_stubs({api.sahara: ('job_binary_get',)}) @test.create_stubs({api.sahara: ('job_binary_get',)})
def test_details(self): def test_details(self):
api.sahara.job_binary_get(IsA(http.HttpRequest), IsA(unicode)) \ api.sahara.job_binary_get(IsA(http.HttpRequest), IsA(six.text_type)) \
.MultipleTimes().AndReturn(self.job_binaries.first()) .MultipleTimes().AndReturn(self.job_binaries.first())
self.mox.ReplayAll() self.mox.ReplayAll()
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)
@ -54,7 +55,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
def test_delete(self): def test_delete(self):
jb_list = (api.sahara.job_binary_list(IsA(http.HttpRequest)) jb_list = (api.sahara.job_binary_list(IsA(http.HttpRequest))
.AndReturn(self.job_binaries.list())) .AndReturn(self.job_binaries.list()))
api.sahara.job_binary_get(IsA(http.HttpRequest), IsA(unicode)) \ api.sahara.job_binary_get(IsA(http.HttpRequest), IsA(six.text_type)) \
.AndReturn(self.job_binaries.list()[0]) .AndReturn(self.job_binaries.list()[0])
api.sahara.job_binary_delete(IsA(http.HttpRequest), jb_list[0].id) api.sahara.job_binary_delete(IsA(http.HttpRequest), jb_list[0].id)
int_id = jb_list[0].url.split("//")[1] int_id = jb_list[0].url.split("//")[1]
@ -67,7 +68,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
@test.create_stubs({api.sahara: ('job_binary_get', @test.create_stubs({api.sahara: ('job_binary_get',
'job_binary_get_file')}) 'job_binary_get_file')})
def test_download(self): def test_download(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.list()[0]) .AndReturn(self.job_binaries.list()[0])
api.sahara.job_binary_get_file(IsA(http.HttpRequest), jb.id) \ api.sahara.job_binary_get_file(IsA(http.HttpRequest), jb.id) \
.AndReturn("TEST FILE CONTENT") .AndReturn("TEST FILE CONTENT")
@ -82,7 +83,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
@test.create_stubs({api.sahara: ('job_binary_get', @test.create_stubs({api.sahara: ('job_binary_get',
'job_binary_get_file')}) 'job_binary_get_file')})
def test_download_with_spaces(self): def test_download_with_spaces(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.list()[1]) .AndReturn(self.job_binaries.list()[1])
api.sahara.job_binary_get_file(IsA(http.HttpRequest), jb.id) \ api.sahara.job_binary_get_file(IsA(http.HttpRequest), jb.id) \
.AndReturn("MORE TEST FILE CONTENT") .AndReturn("MORE TEST FILE CONTENT")

View File

@ -14,6 +14,7 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard.contrib.sahara import api from openstack_dashboard.contrib.sahara import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -43,7 +44,7 @@ class DataProcessingJobExecutionTests(test.TestCase):
@test.create_stubs({api.sahara: ('job_execution_get',)}) @test.create_stubs({api.sahara: ('job_execution_get',)})
def test_details(self): def test_details(self):
api.sahara.job_execution_get(IsA(http.HttpRequest), IsA(unicode)) \ api.sahara.job_execution_get(IsA(http.HttpRequest), IsA(six.text_type)) \
.MultipleTimes().AndReturn(self.job_executions.first()) .MultipleTimes().AndReturn(self.job_executions.first())
self.mox.ReplayAll() self.mox.ReplayAll()
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)

View File

@ -14,6 +14,7 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard.contrib.sahara import api from openstack_dashboard.contrib.sahara import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -38,7 +39,7 @@ class DataProcessingJobTests(test.TestCase):
@test.create_stubs({api.sahara: ('job_get',)}) @test.create_stubs({api.sahara: ('job_get',)})
def test_details(self): def test_details(self):
api.sahara.job_get(IsA(http.HttpRequest), IsA(unicode)) \ api.sahara.job_get(IsA(http.HttpRequest), IsA(six.text_type)) \
.MultipleTimes().AndReturn(self.jobs.first()) .MultipleTimes().AndReturn(self.jobs.first())
self.mox.ReplayAll() self.mox.ReplayAll()
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)

View File

@ -15,6 +15,7 @@ from django import http
from mox3.mox import IgnoreArg # noqa from mox3.mox import IgnoreArg # noqa
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard import api as dash_api from openstack_dashboard import api as dash_api
from openstack_dashboard.contrib.sahara import api from openstack_dashboard.contrib.sahara import api
@ -55,7 +56,7 @@ class DataProcessingNodeGroupTests(test.TestCase):
dash_api.nova.flavor_get(IsA(http.HttpRequest), flavor.id) \ dash_api.nova.flavor_get(IsA(http.HttpRequest), flavor.id) \
.AndReturn(flavor) .AndReturn(flavor)
api.sahara.nodegroup_template_get(IsA(http.HttpRequest), api.sahara.nodegroup_template_get(IsA(http.HttpRequest),
IsA(unicode)) \ IsA(six.text_type)) \
.MultipleTimes().AndReturn(ngt) .MultipleTimes().AndReturn(ngt)
self.mox.ReplayAll() self.mox.ReplayAll()
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)

View File

@ -14,6 +14,8 @@ import logging
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import six
from horizon import forms from horizon import forms
from horizon import workflows from horizon import workflows
@ -133,8 +135,9 @@ def parse_configs_from_context(context, defaults):
config = key_split[2] config = key_split[2]
if service not in configs_dict: if service not in configs_dict:
configs_dict[service] = dict() configs_dict[service] = dict()
if (val is None or if val is None:
unicode(defaults[service][config]) == unicode(val)): continue
if six.text_type(defaults[service][config]) == six.text_type(val):
continue continue
configs_dict[service][config] = val configs_dict[service][config] = val
return configs_dict return configs_dict

View File

@ -15,6 +15,7 @@
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard.contrib.trove import api from openstack_dashboard.contrib.trove import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -139,7 +140,7 @@ class DatabasesBackupsTests(test.TestCase):
@test.create_stubs({api.trove: ('backup_get', 'instance_get')}) @test.create_stubs({api.trove: ('backup_get', 'instance_get')})
def test_detail_backup(self): def test_detail_backup(self):
api.trove.backup_get(IsA(http.HttpRequest), api.trove.backup_get(IsA(http.HttpRequest),
IsA(unicode))\ IsA(six.text_type))\
.AndReturn(self.database_backups.first()) .AndReturn(self.database_backups.first())
api.trove.instance_get(IsA(http.HttpRequest), api.trove.instance_get(IsA(http.HttpRequest),
@ -155,7 +156,7 @@ class DatabasesBackupsTests(test.TestCase):
@test.create_stubs({api.trove: ('backup_get',)}) @test.create_stubs({api.trove: ('backup_get',)})
def test_detail_backup_notfound(self): def test_detail_backup_notfound(self):
api.trove.backup_get(IsA(http.HttpRequest), api.trove.backup_get(IsA(http.HttpRequest),
IsA(unicode))\ IsA(six.text_type))\
.AndRaise(self.exceptions.trove) .AndRaise(self.exceptions.trove)
self.mox.ReplayAll() self.mox.ReplayAll()
@ -168,7 +169,7 @@ class DatabasesBackupsTests(test.TestCase):
incr_backup = self.database_backups.list()[2] incr_backup = self.database_backups.list()[2]
parent_backup = self.database_backups.list()[1] parent_backup = self.database_backups.list()[1]
api.trove.backup_get(IsA(http.HttpRequest), IsA(unicode))\ api.trove.backup_get(IsA(http.HttpRequest), IsA(six.text_type))\
.AndReturn(incr_backup) .AndReturn(incr_backup)
api.trove.backup_get(IsA(http.HttpRequest), incr_backup.parent_id) \ api.trove.backup_get(IsA(http.HttpRequest), incr_backup.parent_id) \
.AndReturn(parent_backup) .AndReturn(parent_backup)

View File

@ -21,6 +21,7 @@ from django import http
from django.utils import unittest from django.utils import unittest
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from horizon import exceptions from horizon import exceptions
from openstack_dashboard import api as dash_api from openstack_dashboard import api as dash_api
@ -222,12 +223,12 @@ class DatabaseTests(test.TestCase):
# Actual create database call # Actual create database call
api.trove.instance_create( api.trove.instance_create(
IsA(http.HttpRequest), IsA(http.HttpRequest),
IsA(unicode), IsA(six.text_type),
IsA(int), IsA(int),
IsA(unicode), IsA(six.text_type),
databases=None, databases=None,
datastore=IsA(unicode), datastore=IsA(six.text_type),
datastore_version=IsA(unicode), datastore_version=IsA(six.text_type),
restore_point=None, restore_point=None,
replica_of=None, replica_of=None,
users=None, users=None,
@ -283,12 +284,12 @@ class DatabaseTests(test.TestCase):
# Actual create database call # Actual create database call
api.trove.instance_create( api.trove.instance_create(
IsA(http.HttpRequest), IsA(http.HttpRequest),
IsA(unicode), IsA(six.text_type),
IsA(int), IsA(int),
IsA(unicode), IsA(six.text_type),
databases=None, databases=None,
datastore=IsA(unicode), datastore=IsA(six.text_type),
datastore_version=IsA(unicode), datastore_version=IsA(six.text_type),
restore_point=None, restore_point=None,
replica_of=None, replica_of=None,
users=None, users=None,
@ -309,7 +310,7 @@ class DatabaseTests(test.TestCase):
@test.create_stubs( @test.create_stubs(
{api.trove: ('instance_get', 'flavor_get',)}) {api.trove: ('instance_get', 'flavor_get',)})
def _test_details(self, database, with_designate=False): def _test_details(self, database, with_designate=False):
api.trove.instance_get(IsA(http.HttpRequest), IsA(unicode))\ api.trove.instance_get(IsA(http.HttpRequest), IsA(six.text_type))\
.AndReturn(database) .AndReturn(database)
api.trove.flavor_get(IsA(http.HttpRequest), IsA(str))\ api.trove.flavor_get(IsA(http.HttpRequest), IsA(str))\
.AndReturn(self.flavors.first()) .AndReturn(self.flavors.first())
@ -343,7 +344,7 @@ class DatabaseTests(test.TestCase):
user_id = user.name user_id = user.name
# views.py: DetailView.get_data # views.py: DetailView.get_data
api.trove.instance_get(IsA(http.HttpRequest), IsA(unicode))\ api.trove.instance_get(IsA(http.HttpRequest), IsA(six.text_type))\
.AndReturn(database) .AndReturn(database)
api.trove.flavor_get(IsA(http.HttpRequest), IsA(str))\ api.trove.flavor_get(IsA(http.HttpRequest), IsA(str))\
.AndReturn(self.flavors.first()) .AndReturn(self.flavors.first())
@ -378,7 +379,7 @@ class DatabaseTests(test.TestCase):
database_size = database.volume.get('size') database_size = database.volume.get('size')
# views.py: DetailView.get_data # views.py: DetailView.get_data
api.trove.instance_get(IsA(http.HttpRequest), IsA(unicode))\ api.trove.instance_get(IsA(http.HttpRequest), IsA(six.text_type))\
.AndReturn(database) .AndReturn(database)
# forms.py: ResizeVolumeForm.handle # forms.py: ResizeVolumeForm.handle
@ -405,7 +406,7 @@ class DatabaseTests(test.TestCase):
database_size = database.volume.get('size') database_size = database.volume.get('size')
# views.py: DetailView.get_data # views.py: DetailView.get_data
api.trove.instance_get(IsA(http.HttpRequest), IsA(unicode))\ api.trove.instance_get(IsA(http.HttpRequest), IsA(six.text_type))\
.AndReturn(database) .AndReturn(database)
self.mox.ReplayAll() self.mox.ReplayAll()
@ -511,18 +512,18 @@ class DatabaseTests(test.TestCase):
nics = [{"net-id": self.networks.first().id, "v4-fixed-ip": ''}] nics = [{"net-id": self.networks.first().id, "v4-fixed-ip": ''}]
api.trove.instance_get(IsA(http.HttpRequest), IsA(unicode))\ api.trove.instance_get(IsA(http.HttpRequest), IsA(six.text_type))\
.AndReturn(self.databases.first()) .AndReturn(self.databases.first())
# Actual create database call # Actual create database call
api.trove.instance_create( api.trove.instance_create(
IsA(http.HttpRequest), IsA(http.HttpRequest),
IsA(unicode), IsA(six.text_type),
IsA(int), IsA(int),
IsA(unicode), IsA(six.text_type),
databases=None, databases=None,
datastore=IsA(unicode), datastore=IsA(six.text_type),
datastore_version=IsA(unicode), datastore_version=IsA(six.text_type),
restore_point=None, restore_point=None,
replica_of=self.databases.first().id, replica_of=self.databases.first().id,
users=None, users=None,

View File

@ -22,6 +22,8 @@ from django.core.urlresolvers import reverse_lazy
from django.utils.datastructures import SortedDict from django.utils.datastructures import SortedDict
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions from horizon import exceptions
from horizon import forms as horizon_forms from horizon import forms as horizon_forms
from horizon import tables as horizon_tables from horizon import tables as horizon_tables
@ -58,7 +60,8 @@ class IndexView(horizon_tables.DataTableView):
flavors = [] flavors = []
msg = _('Unable to retrieve database size information.') msg = _('Unable to retrieve database size information.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
return SortedDict((unicode(flavor.id), flavor) for flavor in flavors) return SortedDict((six.text_type(flavor.id), flavor)
for flavor in flavors)
def _extra_data(self, instance): def _extra_data(self, instance):
flavor = self.get_flavors().get(instance.flavor["id"]) flavor = self.get_flavors().get(instance.flavor["id"])

View File

@ -81,7 +81,7 @@ class UsageTable(tables.DataTable):
def name(self): def name(self):
# slugify was introduced in Django 1.5 # slugify was introduced in Django 1.5
if hasattr(text, 'slugify'): if hasattr(text, 'slugify'):
return text.slugify(unicode(self.title)) return text.slugify(six.text_type(self.title))
else: else:
return self.title return self.title

View File

@ -15,6 +15,7 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -82,7 +83,7 @@ class MeteringLineChartTabTests(test.BaseAdminViewTests):
), }) ), })
def test_stats_for_line_chart(self): def test_stats_for_line_chart(self):
api.ceilometer.sample_list(IsA(http.HttpRequest), api.ceilometer.sample_list(IsA(http.HttpRequest),
IsA(unicode), IsA(six.text_type),
limit=IsA(int)).AndReturn([]) limit=IsA(int)).AndReturn([])
api.ceilometer.statistic_list(IsA(http.HttpRequest), api.ceilometer.statistic_list(IsA(http.HttpRequest),
'memory', 'memory',
@ -115,7 +116,7 @@ class MeteringLineChartTabTests(test.BaseAdminViewTests):
), }) ), })
def test_stats_for_line_chart_attr_max(self): def test_stats_for_line_chart_attr_max(self):
api.ceilometer.sample_list(IsA(http.HttpRequest), api.ceilometer.sample_list(IsA(http.HttpRequest),
IsA(unicode), IsA(six.text_type),
limit=IsA(int)).AndReturn([]) limit=IsA(int)).AndReturn([])
api.ceilometer.statistic_list(IsA(http.HttpRequest), api.ceilometer.statistic_list(IsA(http.HttpRequest),
'memory', period=IsA(int), 'memory', period=IsA(int),
@ -149,7 +150,7 @@ class MeteringLineChartTabTests(test.BaseAdminViewTests):
), }) ), })
def test_stats_for_line_chart_no_group(self): def test_stats_for_line_chart_no_group(self):
api.ceilometer.sample_list(IsA(http.HttpRequest), api.ceilometer.sample_list(IsA(http.HttpRequest),
IsA(unicode), IsA(six.text_type),
limit=IsA(int)).AndReturn([]) limit=IsA(int)).AndReturn([])
api.ceilometer.resource_list(IsA(http.HttpRequest), query=None, api.ceilometer.resource_list(IsA(http.HttpRequest), query=None,
ceilometer_usage_object=None)\ ceilometer_usage_object=None)\

View File

@ -22,6 +22,7 @@ from django import http
from django.utils.http import urlencode from django.utils.http import urlencode
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.dashboards.project.access_and_security \ from openstack_dashboard.dashboards.project.access_and_security \
@ -269,7 +270,7 @@ class FloatingIpViewTests(test.TestCase):
url = allocate_link.get_link_url() url = allocate_link.get_link_url()
classes = (list(allocate_link.get_default_classes()) classes = (list(allocate_link.get_default_classes())
+ list(allocate_link.classes)) + list(allocate_link.classes))
link_name = "%s (%s)" % (unicode(allocate_link.verbose_name), link_name = "%s (%s)" % (six.text_type(allocate_link.verbose_name),
"Quota exceeded") "Quota exceeded")
expected_string = ("<a href='%s' title='%s' class='%s disabled' " expected_string = ("<a href='%s' title='%s' class='%s disabled' "
"id='floating_ips__action_allocate'>" "id='floating_ips__action_allocate'>"

View File

@ -20,6 +20,7 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.dashboards.project.access_and_security.\ from openstack_dashboard.dashboards.project.access_and_security.\
@ -180,7 +181,7 @@ class KeyPairViewTests(test.TestCase):
url = reverse('horizon:project:access_and_security:keypairs:import') url = reverse('horizon:project:access_and_security:keypairs:import')
res = self.client.post(url, formData, follow=True) res = self.client.post(url, formData, follow=True)
self.assertEqual(res.redirect_chain, []) self.assertEqual(res.redirect_chain, [])
msg = unicode(KEYPAIR_ERROR_MESSAGES['invalid']) msg = six.text_type(KEYPAIR_ERROR_MESSAGES['invalid'])
self.assertFormErrors(res, count=1, message=msg) self.assertFormErrors(res, count=1, message=msg)
@test.create_stubs({api.nova: ("keypair_create",)}) @test.create_stubs({api.nova: ("keypair_create",)})

View File

@ -23,6 +23,8 @@ from django.core.urlresolvers import reverse
from django.forms import ValidationError # noqa from django.forms import ValidationError # noqa
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions from horizon import exceptions
from horizon import forms from horizon import forms
from horizon import messages from horizon import messages
@ -399,7 +401,8 @@ class AddRule(forms.SelfHandlingForm):
data['cidr'], data['cidr'],
data['security_group']) data['security_group'])
messages.success(request, messages.success(request,
_('Successfully added rule: %s') % unicode(rule)) _('Successfully added rule: %s')
% six.text_type(rule))
return rule return rule
except Exception: except Exception:
redirect = reverse("horizon:project:access_and_security:" redirect = reverse("horizon:project:access_and_security:"

View File

@ -18,6 +18,7 @@ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy from django.utils.translation import ungettext_lazy
from horizon import tables from horizon import tables
import six
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard import policy from openstack_dashboard import policy
@ -243,7 +244,7 @@ def filter_direction(direction):
def filter_protocol(protocol): def filter_protocol(protocol):
if protocol is None: if protocol is None:
return _('Any') return _('Any')
return unicode.upper(protocol) return six.text_type.upper(protocol)
def check_rule_template(port, ip_proto): def check_rule_template(port, ip_proto):
@ -280,7 +281,7 @@ class RulesTable(tables.DataTable):
return filters.get_int_or_uuid(obj_id) return filters.get_int_or_uuid(obj_id)
def get_object_display(self, rule): def get_object_display(self, rule):
return unicode(rule) return six.text_type(rule)
class Meta(object): class Meta(object):
name = "rules" name = "rules"

View File

@ -21,6 +21,7 @@ from copy import deepcopy # noqa
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from horizon.workflows import views from horizon.workflows import views
from openstack_dashboard import api from openstack_dashboard import api
@ -220,7 +221,7 @@ class SecurityGroupTabTests(test.TestCase):
url = create_link.get_link_url() url = create_link.get_link_url()
classes = (list(create_link.get_default_classes()) classes = (list(create_link.get_default_classes())
+ list(create_link.classes)) + list(create_link.classes))
link_name = "%s (%s)" % (unicode(create_link.verbose_name), link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded") "Quota exceeded")
expected_string = "<a href='%s' title='%s' class='%s disabled' "\ expected_string = "<a href='%s' title='%s' class='%s disabled' "\
"id='security_groups__action_create'>" \ "id='security_groups__action_create'>" \

View File

@ -25,6 +25,7 @@ from django import http
from django.utils import http as utils_http from django.utils import http as utils_http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.dashboards.project.containers import forms from openstack_dashboard.dashboards.project.containers import forms
@ -110,7 +111,7 @@ class SwiftTests(test.TestCase):
handled = table.maybe_handle() handled = table.maybe_handle()
self.assertEqual(handled.status_code, 302) self.assertEqual(handled.status_code, 302)
self.assertEqual(unicode(list(req._messages)[0].message), self.assertEqual(six.text_type(list(req._messages)[0].message),
u"The container cannot be deleted " u"The container cannot be deleted "
u"since it is not empty.") u"since it is not empty.")

View File

@ -23,6 +23,7 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from horizon import exceptions from horizon import exceptions
@ -114,7 +115,7 @@ class ImagesAndSnapshotsTests(test.TestCase):
row_actions = snaps.get_row_actions(snaps.data[2]) row_actions = snaps.get_row_actions(snaps.data[2])
# third instance - status queued, only delete is available # third instance - status queued, only delete is available
self.assertEqual(len(row_actions), 1) self.assertEqual(len(row_actions), 1)
self.assertEqual(unicode(row_actions[0].verbose_name), self.assertEqual(six.text_type(row_actions[0].verbose_name),
u"Delete Image") u"Delete Image")
self.assertEqual(str(row_actions[0]), "<DeleteImage: delete>") self.assertEqual(str(row_actions[0]), "<DeleteImage: delete>")

View File

@ -30,6 +30,7 @@ from django.utils import encoding
from django.utils.http import urlencode from django.utils.http import urlencode
from mox3.mox import IgnoreArg # noqa from mox3.mox import IgnoreArg # noqa
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from horizon import exceptions from horizon import exceptions
from horizon import forms from horizon import forms
@ -503,7 +504,8 @@ class InstanceTests(helpers.TestCase):
api.nova.server_list(IsA(http.HttpRequest), search_opts=search_opts) \ api.nova.server_list(IsA(http.HttpRequest), search_opts=search_opts) \
.AndReturn([servers, False]) .AndReturn([servers, False])
api.network.servers_update_addresses(IsA(http.HttpRequest), servers) api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.server_suspend(IsA(http.HttpRequest), unicode(server.id)) api.nova.server_suspend(IsA(http.HttpRequest),
six.text_type(server.id))
self.mox.ReplayAll() self.mox.ReplayAll()
@ -533,7 +535,7 @@ class InstanceTests(helpers.TestCase):
api.nova.server_list(IsA(http.HttpRequest), search_opts=search_opts) \ api.nova.server_list(IsA(http.HttpRequest), search_opts=search_opts) \
.AndReturn([servers, False]) .AndReturn([servers, False])
api.network.servers_update_addresses(IsA(http.HttpRequest), servers) api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.server_suspend(IsA(http.HttpRequest), unicode(server.id)) \ api.nova.server_suspend(IsA(http.HttpRequest), six.text_type(server.id)) \
.AndRaise(self.exceptions.nova) .AndRaise(self.exceptions.nova)
self.mox.ReplayAll() self.mox.ReplayAll()
@ -565,7 +567,7 @@ class InstanceTests(helpers.TestCase):
api.nova.server_list(IsA(http.HttpRequest), search_opts=search_opts) \ api.nova.server_list(IsA(http.HttpRequest), search_opts=search_opts) \
.AndReturn([servers, False]) .AndReturn([servers, False])
api.network.servers_update_addresses(IsA(http.HttpRequest), servers) api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.server_resume(IsA(http.HttpRequest), unicode(server.id)) api.nova.server_resume(IsA(http.HttpRequest), six.text_type(server.id))
self.mox.ReplayAll() self.mox.ReplayAll()
@ -597,7 +599,7 @@ class InstanceTests(helpers.TestCase):
.AndReturn([servers, False]) .AndReturn([servers, False])
api.network.servers_update_addresses(IsA(http.HttpRequest), servers) api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.server_resume(IsA(http.HttpRequest), api.nova.server_resume(IsA(http.HttpRequest),
unicode(server.id)) \ six.text_type(server.id)) \
.AndRaise(self.exceptions.nova) .AndRaise(self.exceptions.nova)
self.mox.ReplayAll() self.mox.ReplayAll()
@ -3286,7 +3288,7 @@ class InstanceTests(helpers.TestCase):
launch = tables.LaunchLink() launch = tables.LaunchLink()
url = launch.get_link_url() url = launch.get_link_url()
classes = list(launch.get_default_classes()) + list(launch.classes) classes = list(launch.get_default_classes()) + list(launch.classes)
link_name = "%s (%s)" % (unicode(launch.verbose_name), link_name = "%s (%s)" % (six.text_type(launch.verbose_name),
"Quota exceeded") "Quota exceeded")
res = self.client.get(INDEX_URL) res = self.client.get(INDEX_URL)

View File

@ -16,6 +16,8 @@ from django.core.urlresolvers import reverse
from django import http from django import http
from django.utils.html import escape from django.utils.html import escape
import six
from horizon.workflows import views from horizon.workflows import views
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
@ -1854,7 +1856,7 @@ class NetworkViewTests(test.TestCase):
url = create_link.get_link_url() url = create_link.get_link_url()
classes = (list(create_link.get_default_classes()) classes = (list(create_link.get_default_classes())
+ list(create_link.classes)) + list(create_link.classes))
link_name = "%s (%s)" % (unicode(create_link.verbose_name), link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded") "Quota exceeded")
expected_string = "<a href='%s' title='%s' class='%s disabled' "\ expected_string = "<a href='%s' title='%s' class='%s disabled' "\
"id='networks__action_create'>" \ "id='networks__action_create'>" \
@ -1873,7 +1875,7 @@ class NetworkViewTests(test.TestCase):
url = reverse(create_link.get_link_url(), args=[network_id]) url = reverse(create_link.get_link_url(), args=[network_id])
classes = (list(create_link.get_default_classes()) classes = (list(create_link.get_default_classes())
+ list(create_link.classes)) + list(create_link.classes))
link_name = "%s (%s)" % (unicode(create_link.verbose_name), link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded") "Quota exceeded")
expected_string = "<a href='%s' class='%s disabled' "\ expected_string = "<a href='%s' class='%s disabled' "\
"id='networks__row_%s__action_subnet'>%s</a>" \ "id='networks__row_%s__action_subnet'>%s</a>" \
@ -1924,7 +1926,7 @@ class NetworkViewTests(test.TestCase):
url = create_link.get_link_url() url = create_link.get_link_url()
classes = (list(create_link.get_default_classes()) classes = (list(create_link.get_default_classes())
+ list(create_link.classes)) + list(create_link.classes))
link_name = "%s (%s)" % (unicode(create_link.verbose_name), link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded") "Quota exceeded")
expected_string = "<a href='%s' title='%s' class='%s disabled' "\ expected_string = "<a href='%s' title='%s' class='%s disabled' "\
"id='subnets__action_create'>" \ "id='subnets__action_create'>" \

View File

@ -18,6 +18,7 @@ from django import http
from mox3.mox import IgnoreArg # noqa from mox3.mox import IgnoreArg # noqa
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.dashboards.project.routers.extensions.routerrules\ from openstack_dashboard.dashboards.project.routers.extensions.routerrules\
@ -946,7 +947,7 @@ class RouterViewTests(RouterMixin, test.TestCase):
url = create_link.get_link_url() url = create_link.get_link_url()
classes = (list(create_link.get_default_classes()) classes = (list(create_link.get_default_classes())
+ list(create_link.classes)) + list(create_link.classes))
link_name = "%s (%s)" % (unicode(create_link.verbose_name), link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded") "Quota exceeded")
expected_string = "<a href='%s' title='%s' class='%s disabled' "\ expected_string = "<a href='%s' title='%s' class='%s disabled' "\
"id='Routers__action_create'>" \ "id='Routers__action_create'>" \

View File

@ -150,7 +150,7 @@ class TemplateForm(forms.SelfHandlingForm):
validated = api.heat.template_validate(self.request, **kwargs) validated = api.heat.template_validate(self.request, **kwargs)
cleaned['template_validate'] = validated cleaned['template_validate'] = validated
except Exception as e: except Exception as e:
raise forms.ValidationError(unicode(e)) raise forms.ValidationError(six.text_type(e))
return cleaned return cleaned

View File

@ -22,6 +22,7 @@ from django.test.utils import override_settings # noqa
from django.utils import html from django.utils import html
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -626,7 +627,7 @@ class StackTests(test.TestCase):
'disable_rollback': True, 'disable_rollback': True,
'timeout_mins': 61, 'timeout_mins': 61,
'password': 'password', 'password': 'password',
'template': IsA(unicode), 'template': IsA(six.text_type),
'parameters': IsA(dict) 'parameters': IsA(dict)
} }
api.heat.stack_update(IsA(http.HttpRequest), api.heat.stack_update(IsA(http.HttpRequest),

View File

@ -23,6 +23,7 @@ from django import http
from django.test.utils import override_settings from django.test.utils import override_settings
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
import six
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.api import cinder from openstack_dashboard.api import cinder
@ -1011,7 +1012,7 @@ class VolumeViewTests(test.TestCase):
classes = (list(create_link.get_default_classes()) classes = (list(create_link.get_default_classes())
+ list(create_link.classes)) + list(create_link.classes))
link_name = "%s (%s)" % (unicode(create_link.verbose_name), link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded") "Quota exceeded")
expected_string = "<a href='%s' class=\"%s disabled\" "\ expected_string = "<a href='%s' class=\"%s disabled\" "\
"id=\"volumes__row_%s__action_snapshots\">%s</a>" \ "id=\"volumes__row_%s__action_snapshots\">%s</a>" \
@ -1054,7 +1055,7 @@ class VolumeViewTests(test.TestCase):
url = create_link.get_link_url() url = create_link.get_link_url()
classes = (list(create_link.get_default_classes()) classes = (list(create_link.get_default_classes())
+ list(create_link.classes)) + list(create_link.classes))
link_name = "%s (%s)" % (unicode(create_link.verbose_name), link_name = "%s (%s)" % (six.text_type(create_link.verbose_name),
"Quota exceeded") "Quota exceeded")
expected_string = "<a href='%s' title='%s' class='%s disabled' "\ expected_string = "<a href='%s' title='%s' class='%s disabled' "\
"id='volumes__action_create' data-update-url=" \ "id='volumes__action_create' data-update-url=" \

View File

@ -19,6 +19,7 @@
from __future__ import absolute_import from __future__ import absolute_import
from keystoneclient.v2_0 import client as keystone_client from keystoneclient.v2_0 import client as keystone_client
import six
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -90,7 +91,7 @@ class ServiceAPITests(test.APITestCase):
identity_data['id'] = 1 identity_data['id'] = 1
region = identity_data["endpoints"][0]["region"] region = identity_data["endpoints"][0]["region"]
service = api.keystone.Service(identity_data, region) service = api.keystone.Service(identity_data, region)
self.assertEqual(u"identity (native backend)", unicode(service)) self.assertEqual(u"identity (native backend)", six.text_type(service))
self.assertEqual(identity_data["endpoints"][0]["region"], self.assertEqual(identity_data["endpoints"][0]["region"],
service.region) service.region)
self.assertEqual("http://int.keystone.example.com:5000/v2.0", self.assertEqual("http://int.keystone.example.com:5000/v2.0",
@ -105,7 +106,7 @@ class ServiceAPITests(test.APITestCase):
compute_data['id'] = 1 compute_data['id'] = 1
region = compute_data["endpoints"][1]["region"] region = compute_data["endpoints"][1]["region"]
service = api.keystone.Service(compute_data, region) service = api.keystone.Service(compute_data, region)
self.assertEqual(u"compute", unicode(service)) self.assertEqual(u"compute", six.text_type(service))
self.assertEqual(compute_data["endpoints"][1]["region"], self.assertEqual(compute_data["endpoints"][1]["region"],
service.region) service.region)
self.assertEqual("http://int.nova2.example.com:8774/v2", self.assertEqual("http://int.nova2.example.com:8774/v2",

View File

@ -43,6 +43,7 @@ from neutronclient.v2_0 import client as neutron_client
from novaclient.v2 import client as nova_client from novaclient.v2 import client as nova_client
from openstack_auth import user from openstack_auth import user
from openstack_auth import utils from openstack_auth import utils
import six
from six import moves from six import moves
from swiftclient import client as swift_client from swiftclient import client as swift_client
@ -261,7 +262,7 @@ class TestCase(horizon_helpers.TestCase):
assert len(errors) == count, \ assert len(errors) == count, \
"%d errors were found on the form, %d expected" % \ "%d errors were found on the form, %d expected" % \
(len(errors), count) (len(errors), count)
if message and message not in unicode(errors): if message and message not in six.text_type(errors):
self.fail("Expected message not found, instead found: %s" self.fail("Expected message not found, instead found: %s"
% ["%s: %s" % (key, [e for e in field_errors]) for % ["%s: %s" % (key, [e for e in field_errors]) for
(key, field_errors) in errors.items()]) (key, field_errors) in errors.items()])

View File

@ -18,6 +18,7 @@ import glanceclient.exc as glance_exceptions
from keystoneclient import exceptions as keystone_exceptions from keystoneclient import exceptions as keystone_exceptions
from neutronclient.common import exceptions as neutron_exceptions from neutronclient.common import exceptions as neutron_exceptions
from novaclient import exceptions as nova_exceptions from novaclient import exceptions as nova_exceptions
import six
from swiftclient import client as swift_exceptions from swiftclient import client as swift_exceptions
from troveclient import exceptions as trove_exceptions from troveclient import exceptions as trove_exceptions
@ -46,7 +47,7 @@ def create_stubbed_exception(cls, status_code=500):
return str(self.message) return str(self.message)
def fake_unicode(self): def fake_unicode(self):
return unicode(self.message) return six.text_type(self.message)
cls.__init__ = fake_init_exception cls.__init__ = fake_init_exception
cls.__str__ = fake_str cls.__str__ = fake_str