Python3: Add support for unicode, basestring, long
Replaced basestring with six.string_types Replaced (int, long) with six.integer_types Replaced unicode with six.text_type This patch is generated by the following tool using 'basestring', 'long' and 'unicode' options. Manually replaced unicode(ex) with oslo_utils.encodeutils(ex) https://github.com/haypo/sixer Command: python sixer.py -w 'basestring,long,unicode' trove/ Partially implements: blueprint trove-python3 Change-Id: I6fa42674060067663ef819247ea793ef3d8aa0da
This commit is contained in:
committed by
Abhishek Kekane
parent
9f877e5ba7
commit
a56301c237
@@ -17,6 +17,7 @@ import abc
|
||||
|
||||
from lxml import etree
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
import routes
|
||||
import six
|
||||
import stevedore
|
||||
@@ -398,7 +399,8 @@ class ExtensionManager(object):
|
||||
LOG.debug('Ext namespace: %s', extension.get_namespace())
|
||||
LOG.debug('Ext updated: %s', extension.get_updated())
|
||||
except AttributeError as ex:
|
||||
LOG.exception(_("Exception loading extension: %s"), unicode(ex))
|
||||
LOG.exception(_("Exception loading extension: %s"),
|
||||
encodeutils.exception_to_unicode(ex))
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class StringConverter(object):
|
||||
# Return known mappings and quoted strings right away.
|
||||
if value in self._object_mappings:
|
||||
return self._object_mappings[value]
|
||||
elif (isinstance(value, basestring) and
|
||||
elif (isinstance(value, six.string_types) and
|
||||
re.match("^'(.*)'|\"(.*)\"$", value)):
|
||||
return value
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import jsonschema
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_service import service
|
||||
from oslo_utils import encodeutils
|
||||
import paste.urlmap
|
||||
import webob
|
||||
import webob.dec
|
||||
@@ -575,7 +576,8 @@ class FaultWrapper(base_wsgi.Middleware):
|
||||
return resp
|
||||
return resp
|
||||
except Exception as ex:
|
||||
LOG.exception(_("Caught error: %s."), unicode(ex))
|
||||
LOG.exception(_("Caught error: %s."),
|
||||
encodeutils.exception_to_unicode(ex))
|
||||
exc = webob.exc.HTTPInternalServerError()
|
||||
return Fault(exc)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
import trove.common.apischema as apischema
|
||||
from trove.common import cfg
|
||||
@@ -269,7 +270,7 @@ class ConfigurationsController(wsgi.Controller):
|
||||
raise exception.UnprocessableEntity(message=msg)
|
||||
|
||||
# integer min/max checking
|
||||
if isinstance(v, (int, long)) and not isinstance(v, bool):
|
||||
if isinstance(v, six.integer_types) and not isinstance(v, bool):
|
||||
if rule.min_size is not None:
|
||||
try:
|
||||
min_value = int(rule.min_size)
|
||||
@@ -307,9 +308,9 @@ class ConfigurationsController(wsgi.Controller):
|
||||
if value_type == "boolean":
|
||||
return bool
|
||||
elif value_type == "string":
|
||||
return basestring
|
||||
return six.string_types
|
||||
elif value_type == "integer":
|
||||
return (int, long)
|
||||
return six.integer_types
|
||||
else:
|
||||
raise exception.TroveError(_(
|
||||
"Invalid or unsupported type defined in the "
|
||||
|
||||
@@ -17,6 +17,8 @@ import collections
|
||||
import os
|
||||
import re
|
||||
|
||||
import six
|
||||
|
||||
|
||||
def update_dict(updates, target):
|
||||
"""Recursively update a target dictionary with given updates.
|
||||
@@ -103,7 +105,7 @@ def build_file_path(base_dir, base_name, *extensions):
|
||||
def to_bytes(value):
|
||||
"""Convert numbers with a byte suffix to bytes.
|
||||
"""
|
||||
if isinstance(value, basestring):
|
||||
if isinstance(value, six.string_types):
|
||||
pattern = re.compile('^(\d+)([K,M,G]{1})$')
|
||||
match = pattern.match(value)
|
||||
if match:
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
import stevedore
|
||||
|
||||
from trove.common import base_exception as exception
|
||||
@@ -71,7 +72,7 @@ class ModuleDriverManager(object):
|
||||
driver.get_type)
|
||||
except AttributeError as ex:
|
||||
LOG.exception(_("Exception loading module driver: %s"),
|
||||
unicode(ex))
|
||||
encodeutils.exception_to_unicode(ex))
|
||||
|
||||
return supported
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
|
||||
from trove.common import exception
|
||||
from trove.common.i18n import _
|
||||
@@ -229,7 +230,7 @@ class QuotaEngine(object):
|
||||
|
||||
if not quota_driver_class:
|
||||
quota_driver_class = CONF.quota_driver
|
||||
if isinstance(quota_driver_class, basestring):
|
||||
if isinstance(quota_driver_class, six.string_types):
|
||||
quota_driver_class = importutils.import_object(quota_driver_class,
|
||||
self._resources)
|
||||
self._driver = quota_driver_class
|
||||
|
||||
@@ -28,6 +28,7 @@ from proboscis import before_class
|
||||
from proboscis.decorators import time_out
|
||||
from proboscis import SkipTest
|
||||
from proboscis import test
|
||||
import six
|
||||
from troveclient.compat import exceptions
|
||||
|
||||
from trove.common.utils import poll_until
|
||||
@@ -227,12 +228,12 @@ class CreateConfigurations(ConfigurationsTestBase):
|
||||
msg="Get Configuration parameter")
|
||||
assert_equal(param_name, config_parameter_dict['name'])
|
||||
with TypeCheck('ConfigurationParameter', param) as parameter:
|
||||
parameter.has_field('name', basestring)
|
||||
parameter.has_field('name', six.string_types)
|
||||
parameter.has_field('restart_required', bool)
|
||||
parameter.has_field('max', (int, long))
|
||||
parameter.has_field('min', (int, long))
|
||||
parameter.has_field('type', basestring)
|
||||
parameter.has_field('datastore_version_id', unicode)
|
||||
parameter.has_field('max', six.integer_types)
|
||||
parameter.has_field('min', six.integer_types)
|
||||
parameter.has_field('type', six.string_types)
|
||||
parameter.has_field('datastore_version_id', six.text_type)
|
||||
|
||||
@test
|
||||
def test_configurations_create_invalid_values(self):
|
||||
@@ -280,12 +281,12 @@ class CreateConfigurations(ConfigurationsTestBase):
|
||||
resp, body = instance_info.dbaas.client.last_response
|
||||
assert_equal(resp.status, 200)
|
||||
with TypeCheck('Configuration', result) as configuration:
|
||||
configuration.has_field('name', basestring)
|
||||
configuration.has_field('description', basestring)
|
||||
configuration.has_field('name', six.string_types)
|
||||
configuration.has_field('description', six.string_types)
|
||||
configuration.has_field('values', dict)
|
||||
configuration.has_field('datastore_name', basestring)
|
||||
configuration.has_field('datastore_version_id', unicode)
|
||||
configuration.has_field('datastore_version_name', basestring)
|
||||
configuration.has_field('datastore_name', six.string_types)
|
||||
configuration.has_field('datastore_version_id', six.text_type)
|
||||
configuration.has_field('datastore_version_name', six.string_types)
|
||||
global configuration_info
|
||||
configuration_info = result
|
||||
assert_equal(configuration_info.name, CONFIG_NAME)
|
||||
@@ -390,12 +391,12 @@ class AfterConfigurationsCreation(ConfigurationsTestBase):
|
||||
|
||||
# check the result field types
|
||||
with TypeCheck("configuration", result) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("description", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("description", six.string_types)
|
||||
check.has_field("values", dict)
|
||||
check.has_field("created", basestring)
|
||||
check.has_field("updated", basestring)
|
||||
check.has_field("created", six.string_types)
|
||||
check.has_field("updated", six.string_types)
|
||||
check.has_field("instance_count", int)
|
||||
|
||||
print(result.values)
|
||||
@@ -425,7 +426,7 @@ class AfterConfigurationsCreation(ConfigurationsTestBase):
|
||||
if param.type == 'integer':
|
||||
check.has_element(item_key, int)
|
||||
if param.type == 'string':
|
||||
check.has_element(item_key, basestring)
|
||||
check.has_element(item_key, six.string_types)
|
||||
if param.type == 'boolean':
|
||||
check.has_element(item_key, bool)
|
||||
|
||||
@@ -456,12 +457,12 @@ class ListConfigurations(ConfigurationsTestBase):
|
||||
result = instance_info.dbaas.configurations.list()
|
||||
for conf in result:
|
||||
with TypeCheck("Configuration", conf) as check:
|
||||
check.has_field('id', basestring)
|
||||
check.has_field('name', basestring)
|
||||
check.has_field('description', basestring)
|
||||
check.has_field('datastore_version_id', basestring)
|
||||
check.has_field('datastore_version_name', basestring)
|
||||
check.has_field('datastore_name', basestring)
|
||||
check.has_field('id', six.string_types)
|
||||
check.has_field('name', six.string_types)
|
||||
check.has_field('description', six.string_types)
|
||||
check.has_field('datastore_version_id', six.string_types)
|
||||
check.has_field('datastore_version_name', six.string_types)
|
||||
check.has_field('datastore_name', six.string_types)
|
||||
|
||||
exists = [config for config in result if
|
||||
config.id == configuration_info.id]
|
||||
|
||||
@@ -19,6 +19,7 @@ from proboscis.asserts import assert_raises
|
||||
from proboscis.asserts import assert_true
|
||||
from proboscis import before_class
|
||||
from proboscis import test
|
||||
import six
|
||||
from troveclient.compat import exceptions
|
||||
|
||||
from trove import tests
|
||||
@@ -27,6 +28,7 @@ from trove.tests.util import create_dbaas_client
|
||||
from trove.tests.util import test_config
|
||||
from trove.tests.util.users import Requirements
|
||||
|
||||
|
||||
GROUP = "dbaas.api.datastores"
|
||||
NAME = "nonexistent"
|
||||
|
||||
@@ -49,8 +51,8 @@ class Datastores(object):
|
||||
datastores = self.rd_client.datastores.list()
|
||||
for datastore in datastores:
|
||||
with TypeCheck('Datastore', datastore) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("links", list)
|
||||
check.has_field("versions", list)
|
||||
|
||||
@@ -60,8 +62,8 @@ class Datastores(object):
|
||||
datastore_by_name = self.rd_client.datastores.get(
|
||||
test_config.dbaas_datastore)
|
||||
with TypeCheck('Datastore', datastore_by_name) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("links", list)
|
||||
assert_equal(datastore_by_name.name, test_config.dbaas_datastore)
|
||||
|
||||
@@ -69,8 +71,8 @@ class Datastores(object):
|
||||
datastore_by_id = self.rd_client.datastores.get(
|
||||
datastore_by_name.id)
|
||||
with TypeCheck('Datastore', datastore_by_id) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("links", list)
|
||||
check.has_field("versions", list)
|
||||
assert_equal(datastore_by_id.id, datastore_by_name.id)
|
||||
@@ -119,8 +121,8 @@ class DatastoreVersions(object):
|
||||
self.datastore_active.name)
|
||||
for version in versions:
|
||||
with TypeCheck('DatastoreVersion', version) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("links", list)
|
||||
|
||||
@test
|
||||
@@ -128,9 +130,9 @@ class DatastoreVersions(object):
|
||||
version = self.rd_client.datastore_versions.get(
|
||||
self.datastore_active.name, self.datastore_version_active.name)
|
||||
with TypeCheck('DatastoreVersion', version) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("datastore", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("datastore", six.string_types)
|
||||
check.has_field("links", list)
|
||||
assert_equal(version.name, self.datastore_version_active.name)
|
||||
|
||||
@@ -139,9 +141,9 @@ class DatastoreVersions(object):
|
||||
version = self.rd_client.datastore_versions.get_by_uuid(
|
||||
self.datastore_version_active.id)
|
||||
with TypeCheck('DatastoreVersion', version) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("datastore", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("datastore", six.string_types)
|
||||
check.has_field("links", list)
|
||||
assert_equal(version.name, self.datastore_version_active.name)
|
||||
|
||||
@@ -161,8 +163,8 @@ class DatastoreVersions(object):
|
||||
self.datastore_active.id)
|
||||
for version in versions:
|
||||
with TypeCheck('DatastoreVersion', version) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("links", list)
|
||||
|
||||
@test
|
||||
@@ -170,9 +172,9 @@ class DatastoreVersions(object):
|
||||
version = self.rd_client.datastore_versions.get(
|
||||
self.datastore_active.id, self.datastore_version_active.id)
|
||||
with TypeCheck('DatastoreVersion', version) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("datastore", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("datastore", six.string_types)
|
||||
check.has_field("links", list)
|
||||
assert_equal(version.name, self.datastore_version_active.name)
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ from proboscis import before_class
|
||||
from proboscis.decorators import time_out
|
||||
from proboscis import SkipTest
|
||||
from proboscis import test
|
||||
import six
|
||||
from troveclient.compat import exceptions
|
||||
|
||||
from trove.common import exception as rd_exceptions
|
||||
@@ -952,11 +953,11 @@ class SecurityGroupsTest(object):
|
||||
def test_created_security_group(self):
|
||||
assert_is_not_none(self.testSecurityGroup)
|
||||
with TypeCheck('SecurityGroup', self.testSecurityGroup) as secGrp:
|
||||
secGrp.has_field('id', basestring)
|
||||
secGrp.has_field('name', basestring)
|
||||
secGrp.has_field('description', basestring)
|
||||
secGrp.has_field('created', basestring)
|
||||
secGrp.has_field('updated', basestring)
|
||||
secGrp.has_field('id', six.string_types)
|
||||
secGrp.has_field('name', six.string_types)
|
||||
secGrp.has_field('description', six.string_types)
|
||||
secGrp.has_field('created', six.string_types)
|
||||
secGrp.has_field('updated', six.string_types)
|
||||
assert_equal(self.testSecurityGroup.name, self.secGroupName)
|
||||
assert_equal(self.testSecurityGroup.description,
|
||||
self.secGroupDescription)
|
||||
|
||||
@@ -18,6 +18,7 @@ from proboscis import asserts
|
||||
from proboscis import before_class
|
||||
from proboscis.decorators import time_out
|
||||
from proboscis import test
|
||||
import six
|
||||
from troveclient.compat import exceptions
|
||||
|
||||
from trove.common.utils import poll_until
|
||||
@@ -190,7 +191,7 @@ class AccountWithBrokenInstance(object):
|
||||
# for having a broken instance in the roster.
|
||||
asserts.assert_equal(len(account_info.instances), 1)
|
||||
instance = account_info.instances[0]
|
||||
asserts.assert_true(isinstance(instance['id'], basestring))
|
||||
asserts.assert_true(isinstance(instance['id'], six.string_types))
|
||||
asserts.assert_equal(len(instance['id']), 36)
|
||||
asserts.assert_equal(instance['name'], self.name)
|
||||
asserts.assert_equal(instance['status'], "ERROR")
|
||||
|
||||
@@ -18,6 +18,7 @@ from proboscis import before_class
|
||||
from proboscis.check import Check
|
||||
from proboscis import SkipTest
|
||||
from proboscis import test
|
||||
import six
|
||||
from troveclient.compat import exceptions
|
||||
|
||||
from trove.common.utils import poll_until
|
||||
@@ -32,6 +33,7 @@ from trove.tests.util import create_client
|
||||
from trove.tests.util import create_dbaas_client
|
||||
from trove.tests.util.users import Requirements
|
||||
|
||||
|
||||
GROUP = "dbaas.api.mgmt.instances"
|
||||
|
||||
|
||||
@@ -45,24 +47,24 @@ def mgmt_index_requires_admin_account():
|
||||
# These functions check some dictionaries in the returned response.
|
||||
def flavor_check(flavor):
|
||||
with CollectionCheck("flavor", flavor) as check:
|
||||
check.has_element("id", basestring)
|
||||
check.has_element("id", six.string_types)
|
||||
check.has_element("links", list)
|
||||
|
||||
|
||||
def datastore_check(datastore):
|
||||
with CollectionCheck("datastore", datastore) as check:
|
||||
check.has_element("type", basestring)
|
||||
check.has_element("version", basestring)
|
||||
check.has_element("type", six.string_types)
|
||||
check.has_element("version", six.string_types)
|
||||
|
||||
|
||||
def guest_status_check(guest_status):
|
||||
with CollectionCheck("guest_status", guest_status) as check:
|
||||
check.has_element("state_description", basestring)
|
||||
check.has_element("state_description", six.string_types)
|
||||
|
||||
|
||||
def volume_check(volume):
|
||||
with CollectionCheck("volume", volume) as check:
|
||||
check.has_element("id", basestring)
|
||||
check.has_element("id", six.string_types)
|
||||
check.has_element("size", int)
|
||||
check.has_element("used", float)
|
||||
check.has_element("total", float)
|
||||
@@ -86,21 +88,21 @@ def mgmt_instance_get():
|
||||
for name in dir(api_instance):
|
||||
print(str(name) + "=" + str(getattr(api_instance, name)))
|
||||
with TypeCheck("instance", api_instance) as instance:
|
||||
instance.has_field('created', basestring)
|
||||
instance.has_field('created', six.string_types)
|
||||
instance.has_field('deleted', bool)
|
||||
# If the instance hasn't been deleted, this should be false... but
|
||||
# lets avoid creating more ordering work.
|
||||
instance.has_field('deleted_at', (basestring, None))
|
||||
instance.has_field('deleted_at', (six.string_types, None))
|
||||
instance.has_field('flavor', dict, flavor_check)
|
||||
instance.has_field('datastore', dict, datastore_check)
|
||||
instance.has_field('guest_status', dict, guest_status_check)
|
||||
instance.has_field('id', basestring)
|
||||
instance.has_field('id', six.string_types)
|
||||
instance.has_field('links', list)
|
||||
instance.has_field('name', basestring)
|
||||
# instance.has_field('server_status', basestring)
|
||||
instance.has_field('status', basestring)
|
||||
instance.has_field('tenant_id', basestring)
|
||||
instance.has_field('updated', basestring)
|
||||
instance.has_field('name', six.string_types)
|
||||
# instance.has_field('server_status', six.string_types)
|
||||
instance.has_field('status', six.string_types)
|
||||
instance.has_field('tenant_id', six.string_types)
|
||||
instance.has_field('updated', six.string_types)
|
||||
# Can be None if no volume is given on this instance.
|
||||
volume_support = CONFIG.get(datastore_type, 'mysql')['volume_support']
|
||||
if volume_support:
|
||||
@@ -119,23 +121,23 @@ def mgmt_instance_get():
|
||||
with CollectionCheck("server", api_instance.server) as server:
|
||||
server.has_element("addresses", dict)
|
||||
server.has_element("deleted", bool)
|
||||
server.has_element("deleted_at", (basestring, None))
|
||||
server.has_element("host", basestring)
|
||||
server.has_element("id", basestring)
|
||||
server.has_element("deleted_at", (six.string_types, None))
|
||||
server.has_element("host", six.string_types)
|
||||
server.has_element("id", six.string_types)
|
||||
server.has_element("local_id", int)
|
||||
server.has_element("name", basestring)
|
||||
server.has_element("status", basestring)
|
||||
server.has_element("tenant_id", basestring)
|
||||
server.has_element("name", six.string_types)
|
||||
server.has_element("status", six.string_types)
|
||||
server.has_element("tenant_id", six.string_types)
|
||||
|
||||
if (volume_support and
|
||||
CONFIG.trove_main_instance_has_volume):
|
||||
with CollectionCheck("volume", api_instance.volume) as volume:
|
||||
volume.has_element("attachments", list)
|
||||
volume.has_element("availability_zone", basestring)
|
||||
volume.has_element("created_at", (basestring, None))
|
||||
volume.has_element("id", basestring)
|
||||
volume.has_element("availability_zone", six.string_types)
|
||||
volume.has_element("created_at", (six.string_types, None))
|
||||
volume.has_element("id", six.string_types)
|
||||
volume.has_element("size", int)
|
||||
volume.has_element("status", basestring)
|
||||
volume.has_element("status", six.string_types)
|
||||
|
||||
|
||||
@test(groups=["fake." + GROUP])
|
||||
@@ -178,21 +180,21 @@ class WhenMgmtInstanceGetIsCalledButServerIsNotReady(object):
|
||||
for name in dir(api_instance):
|
||||
print(str(name) + "=" + str(getattr(api_instance, name)))
|
||||
with TypeCheck("instance", api_instance) as instance:
|
||||
instance.has_field('created', basestring)
|
||||
instance.has_field('created', six.string_types)
|
||||
instance.has_field('deleted', bool)
|
||||
# If the instance hasn't been deleted, this should be false... but
|
||||
# lets avoid creating more ordering work.
|
||||
instance.has_field('deleted_at', (basestring, None))
|
||||
instance.has_field('deleted_at', (six.string_types, None))
|
||||
instance.has_field('flavor', dict, flavor_check)
|
||||
instance.has_field('datastore', dict, datastore_check)
|
||||
instance.has_field('guest_status', dict, guest_status_check)
|
||||
instance.has_field('id', basestring)
|
||||
instance.has_field('id', six.string_types)
|
||||
instance.has_field('links', list)
|
||||
instance.has_field('name', basestring)
|
||||
# instance.has_field('server_status', basestring)
|
||||
instance.has_field('status', basestring)
|
||||
instance.has_field('tenant_id', basestring)
|
||||
instance.has_field('updated', basestring)
|
||||
instance.has_field('name', six.string_types)
|
||||
# instance.has_field('server_status', six.string_types)
|
||||
instance.has_field('status', six.string_types)
|
||||
instance.has_field('tenant_id', six.string_types)
|
||||
instance.has_field('updated', six.string_types)
|
||||
# Can be None if no volume is given on this instance.
|
||||
instance.has_field('server', None)
|
||||
instance.has_field('volume', None)
|
||||
|
||||
@@ -24,6 +24,7 @@ from proboscis import before_class
|
||||
from proboscis import SkipTest
|
||||
from proboscis import test
|
||||
from proboscis import TestProgram
|
||||
import six
|
||||
from troveclient.compat import client as trove_client
|
||||
from troveclient.compat import Dbaas
|
||||
from troveclient.compat import TroveHTTPClient
|
||||
@@ -1008,10 +1009,12 @@ class MgmtHosts(Example):
|
||||
check.equal(1, len(host.instances))
|
||||
for instance in host.instances:
|
||||
check.equal(instance['status'], 'ACTIVE')
|
||||
check.true(isinstance(instance['name'], basestring))
|
||||
check.true(isinstance(instance['id'], basestring))
|
||||
check.true(isinstance(instance['server_id'], basestring))
|
||||
check.true(isinstance(instance['tenant_id'], basestring))
|
||||
check.true(isinstance(instance['name'], six.string_types))
|
||||
check.true(isinstance(instance['id'], six.string_types))
|
||||
check.true(isinstance(instance['server_id'],
|
||||
six.string_types))
|
||||
check.true(isinstance(instance['tenant_id'],
|
||||
six.string_types))
|
||||
|
||||
@test
|
||||
def mgmt_host_update_all(self):
|
||||
@@ -1118,7 +1121,7 @@ class MgmtInstance(Example):
|
||||
@test
|
||||
@for_both
|
||||
def created(self, result):
|
||||
assert_true(isinstance(result.created, basestring))
|
||||
assert_true(isinstance(result.created, six.string_types))
|
||||
|
||||
@test
|
||||
def deleted(self):
|
||||
@@ -1153,8 +1156,8 @@ class MgmtInstance(Example):
|
||||
assert_true(isinstance(result.links, list))
|
||||
for link in result.links:
|
||||
assert_true(isinstance(link, dict))
|
||||
assert_true(isinstance(link['href'], basestring))
|
||||
assert_true(isinstance(link['rel'], basestring))
|
||||
assert_true(isinstance(link['href'], six.string_types))
|
||||
assert_true(isinstance(link['rel'], six.string_types))
|
||||
|
||||
@test
|
||||
def local_id(self):
|
||||
@@ -1164,12 +1167,12 @@ class MgmtInstance(Example):
|
||||
@test
|
||||
@for_both
|
||||
def name(self, result):
|
||||
assert_true(isinstance(result.name, basestring))
|
||||
assert_true(isinstance(result.name, six.string_types))
|
||||
|
||||
@test
|
||||
@for_both
|
||||
def server_id(self, result):
|
||||
assert_true(isinstance(result.server['id'], basestring))
|
||||
assert_true(isinstance(result.server['id'], six.string_types))
|
||||
|
||||
@test
|
||||
@for_both
|
||||
@@ -1189,7 +1192,7 @@ class MgmtInstance(Example):
|
||||
@test
|
||||
@for_both
|
||||
def updated(self, result):
|
||||
assert_true(isinstance(result.updated, basestring))
|
||||
assert_true(isinstance(result.updated, six.string_types))
|
||||
|
||||
@test
|
||||
@for_both
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
import os
|
||||
|
||||
from proboscis import SkipTest
|
||||
import six
|
||||
import time as timer
|
||||
|
||||
from trove.common import cfg
|
||||
@@ -314,13 +315,13 @@ class ClusterActionsRunner(TestRunner):
|
||||
def _assert_cluster_response(self, cluster_id, expected_state):
|
||||
cluster = self.auth_client.clusters.get(cluster_id)
|
||||
with TypeCheck('Cluster', cluster) as check:
|
||||
check.has_field("id", basestring)
|
||||
check.has_field("name", basestring)
|
||||
check.has_field("id", six.string_types)
|
||||
check.has_field("name", six.string_types)
|
||||
check.has_field("datastore", dict)
|
||||
check.has_field("instances", list)
|
||||
check.has_field("links", list)
|
||||
check.has_field("created", unicode)
|
||||
check.has_field("updated", unicode)
|
||||
check.has_field("created", six.text_type)
|
||||
check.has_field("updated", six.text_type)
|
||||
for instance in cluster.instances:
|
||||
isinstance(instance, dict)
|
||||
self.assert_is_not_none(instance['id'])
|
||||
|
||||
Reference in New Issue
Block a user