Merge "Remove usage of six"
This commit is contained in:
commit
242a1265d9
|
@ -10,7 +10,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +20,7 @@ def encode(value, encoding='utf-8'):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if isinstance(value, six.text_type):
|
if isinstance(value, str):
|
||||||
return value.encode(encoding)
|
return value.encode(encoding)
|
||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
|
@ -159,7 +159,7 @@ class BaseTestCase(base.BaseTestCase):
|
||||||
self.fail('Command does not fail as required (%s)' % signature)
|
self.fail('Command does not fail as required (%s)' % signature)
|
||||||
except CommandException as e:
|
except CommandException as e:
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
message, six.text_type(e),
|
message, str(e),
|
||||||
'Command "%s" fails with different message' % e.cmd)
|
'Command "%s" fails with different message' % e.cmd)
|
||||||
|
|
||||||
def resource_provider_create(self,
|
def resource_provider_create(self,
|
||||||
|
@ -178,7 +178,7 @@ class BaseTestCase(base.BaseTestCase):
|
||||||
self.resource_provider_delete(res['uuid'])
|
self.resource_provider_delete(res['uuid'])
|
||||||
except CommandException as exc:
|
except CommandException as exc:
|
||||||
# may have already been deleted by a test case
|
# may have already been deleted by a test case
|
||||||
err_message = six.text_type(exc).lower()
|
err_message = str(exc).lower()
|
||||||
if 'no resource provider' not in err_message:
|
if 'no resource provider' not in err_message:
|
||||||
raise
|
raise
|
||||||
self.addCleanup(cleanup)
|
self.addCleanup(cleanup)
|
||||||
|
@ -255,7 +255,7 @@ class BaseTestCase(base.BaseTestCase):
|
||||||
self.openstack('resource provider allocation delete ' + uuid)
|
self.openstack('resource provider allocation delete ' + uuid)
|
||||||
except CommandException as exc:
|
except CommandException as exc:
|
||||||
# may have already been deleted by a test case
|
# may have already been deleted by a test case
|
||||||
if 'not found' in six.text_type(exc).lower():
|
if 'not found' in str(exc).lower():
|
||||||
pass
|
pass
|
||||||
self.addCleanup(cleanup, consumer_uuid)
|
self.addCleanup(cleanup, consumer_uuid)
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ class BaseTestCase(base.BaseTestCase):
|
||||||
if provider:
|
if provider:
|
||||||
# --provider can be specified multiple times so if we only get
|
# --provider can be specified multiple times so if we only get
|
||||||
# a single string value convert to a list.
|
# a single string value convert to a list.
|
||||||
if isinstance(provider, six.string_types):
|
if isinstance(provider, str):
|
||||||
provider = [provider]
|
provider = [provider]
|
||||||
cmd += ' ' + ' '.join(
|
cmd += ' ' + ' '.join(
|
||||||
'--provider %s' % rp_uuid for rp_uuid in provider)
|
'--provider %s' % rp_uuid for rp_uuid in provider)
|
||||||
|
@ -286,7 +286,7 @@ class BaseTestCase(base.BaseTestCase):
|
||||||
self.openstack('resource provider allocation delete ' + uuid)
|
self.openstack('resource provider allocation delete ' + uuid)
|
||||||
except CommandException as exc:
|
except CommandException as exc:
|
||||||
# may have already been deleted by a test case
|
# may have already been deleted by a test case
|
||||||
if 'not found' in six.text_type(exc).lower():
|
if 'not found' in str(exc).lower():
|
||||||
pass
|
pass
|
||||||
self.addCleanup(cleanup, consumer_uuid)
|
self.addCleanup(cleanup, consumer_uuid)
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ class BaseTestCase(base.BaseTestCase):
|
||||||
self.trait_delete(name)
|
self.trait_delete(name)
|
||||||
except CommandException as exc:
|
except CommandException as exc:
|
||||||
# may have already been deleted by a test case
|
# may have already been deleted by a test case
|
||||||
err_message = six.text_type(exc).lower()
|
err_message = str(exc).lower()
|
||||||
if 'http 404' not in err_message:
|
if 'http 404' not in err_message:
|
||||||
raise
|
raise
|
||||||
self.addCleanup(cleanup)
|
self.addCleanup(cleanup)
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from osc_placement.tests.functional import base
|
from osc_placement.tests.functional import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +89,7 @@ class TestAllocation(base.BaseTestCase):
|
||||||
self.resource_allocation_set,
|
self.resource_allocation_set,
|
||||||
consumer_uuid, [])
|
consumer_uuid, [])
|
||||||
self.assertIn('At least one resource allocation must be specified',
|
self.assertIn('At least one resource allocation must be specified',
|
||||||
six.text_type(exc))
|
str(exc))
|
||||||
|
|
||||||
def test_allocation_delete(self):
|
def test_allocation_delete(self):
|
||||||
consumer_uuid = str(uuid.uuid4())
|
consumer_uuid = str(uuid.uuid4())
|
||||||
|
@ -112,7 +110,7 @@ class TestAllocation(base.BaseTestCase):
|
||||||
msg = "No allocations for consumer '{}'".format(consumer_uuid)
|
msg = "No allocations for consumer '{}'".format(consumer_uuid)
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_allocation_delete, consumer_uuid)
|
self.resource_allocation_delete, consumer_uuid)
|
||||||
self.assertIn(msg, six.text_type(exc))
|
self.assertIn(msg, str(exc))
|
||||||
|
|
||||||
|
|
||||||
class TestAllocation18(base.BaseTestCase):
|
class TestAllocation18(base.BaseTestCase):
|
||||||
|
|
|
@ -14,8 +14,6 @@ import collections
|
||||||
import copy
|
import copy
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from osc_placement.tests.functional import base
|
from osc_placement.tests.functional import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +51,7 @@ class TestInventory(base.BaseTestCase):
|
||||||
self.resource_inventory_show,
|
self.resource_inventory_show,
|
||||||
rp_uuid, 'VCPU')
|
rp_uuid, 'VCPU')
|
||||||
self.assertIn('No inventory of class VCPU for {}'.format(rp_uuid),
|
self.assertIn('No inventory of class VCPU for {}'.format(rp_uuid),
|
||||||
six.text_type(exc))
|
str(exc))
|
||||||
|
|
||||||
def test_inventory_list(self):
|
def test_inventory_list(self):
|
||||||
rp_uuid = self.rp['uuid']
|
rp_uuid = self.rp['uuid']
|
||||||
|
@ -86,14 +84,14 @@ class TestInventory(base.BaseTestCase):
|
||||||
self.resource_inventory_show,
|
self.resource_inventory_show,
|
||||||
rp_uuid, 'VCPU')
|
rp_uuid, 'VCPU')
|
||||||
self.assertIn('No inventory of class VCPU for {}'.format(rp_uuid),
|
self.assertIn('No inventory of class VCPU for {}'.format(rp_uuid),
|
||||||
six.text_type(exc))
|
str(exc))
|
||||||
|
|
||||||
def test_inventory_delete_not_found(self):
|
def test_inventory_delete_not_found(self):
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_inventory_delete,
|
self.resource_inventory_delete,
|
||||||
self.rp['uuid'], 'VCPU')
|
self.rp['uuid'], 'VCPU')
|
||||||
self.assertIn('No inventory of class VCPU found for delete',
|
self.assertIn('No inventory of class VCPU found for delete',
|
||||||
six.text_type(exc))
|
str(exc))
|
||||||
|
|
||||||
def test_delete_all_inventories(self):
|
def test_delete_all_inventories(self):
|
||||||
# Negative test to assert command failure because
|
# Negative test to assert command failure because
|
||||||
|
@ -109,7 +107,7 @@ class TestSetInventory(base.BaseTestCase):
|
||||||
exc = self.assertRaises(
|
exc = self.assertRaises(
|
||||||
base.CommandException,
|
base.CommandException,
|
||||||
self.openstack, 'resource provider inventory set')
|
self.openstack, 'resource provider inventory set')
|
||||||
self.assertIn(base.ARGUMENTS_MISSING, six.text_type(exc))
|
self.assertIn(base.ARGUMENTS_MISSING, str(exc))
|
||||||
|
|
||||||
def test_set_empty_inventories(self):
|
def test_set_empty_inventories(self):
|
||||||
rp = self.resource_provider_create()
|
rp = self.resource_provider_create()
|
||||||
|
@ -121,30 +119,30 @@ class TestSetInventory(base.BaseTestCase):
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_inventory_set,
|
self.resource_inventory_set,
|
||||||
rp['uuid'], 'VCPU')
|
rp['uuid'], 'VCPU')
|
||||||
self.assertIn('must have "name=value"', six.text_type(exc))
|
self.assertIn('must have "name=value"', str(exc))
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_inventory_set,
|
self.resource_inventory_set,
|
||||||
rp['uuid'], 'VCPU==')
|
rp['uuid'], 'VCPU==')
|
||||||
self.assertIn('must have "name=value"', six.text_type(exc))
|
self.assertIn('must have "name=value"', str(exc))
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_inventory_set,
|
self.resource_inventory_set,
|
||||||
rp['uuid'], '=10')
|
rp['uuid'], '=10')
|
||||||
self.assertIn('must be not empty', six.text_type(exc))
|
self.assertIn('must be not empty', str(exc))
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_inventory_set,
|
self.resource_inventory_set,
|
||||||
rp['uuid'], 'v=')
|
rp['uuid'], 'v=')
|
||||||
self.assertIn('must be not empty', six.text_type(exc))
|
self.assertIn('must be not empty', str(exc))
|
||||||
|
|
||||||
# unknown class
|
# unknown class
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_inventory_set,
|
self.resource_inventory_set,
|
||||||
rp['uuid'], 'UNKNOWN_CPU=16')
|
rp['uuid'], 'UNKNOWN_CPU=16')
|
||||||
self.assertIn('Unknown resource class', six.text_type(exc))
|
self.assertIn('Unknown resource class', str(exc))
|
||||||
# unknown property
|
# unknown property
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_inventory_set,
|
self.resource_inventory_set,
|
||||||
rp['uuid'], 'VCPU:fake=16')
|
rp['uuid'], 'VCPU:fake=16')
|
||||||
self.assertIn('Unknown inventory field', six.text_type(exc))
|
self.assertIn('Unknown inventory field', str(exc))
|
||||||
|
|
||||||
def test_set_multiple_classes(self):
|
def test_set_multiple_classes(self):
|
||||||
rp = self.resource_provider_create()
|
rp = self.resource_provider_create()
|
||||||
|
@ -178,7 +176,7 @@ class TestSetInventory(base.BaseTestCase):
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_inventory_set,
|
self.resource_inventory_set,
|
||||||
rp['uuid'], 'VCPU=8', 'UNKNOWN=4')
|
rp['uuid'], 'VCPU=8', 'UNKNOWN=4')
|
||||||
self.assertIn('Unknown resource class', six.text_type(exc))
|
self.assertIn('Unknown resource class', str(exc))
|
||||||
self.assertEqual([], self.resource_inventory_list(rp['uuid']))
|
self.assertEqual([], self.resource_inventory_list(rp['uuid']))
|
||||||
|
|
||||||
def test_replace_previous_values(self):
|
def test_replace_previous_values(self):
|
||||||
|
@ -205,24 +203,24 @@ class TestSetInventory(base.BaseTestCase):
|
||||||
exc = self.assertRaises(
|
exc = self.assertRaises(
|
||||||
base.CommandException,
|
base.CommandException,
|
||||||
self.openstack, 'resource provider inventory class set')
|
self.openstack, 'resource provider inventory class set')
|
||||||
self.assertIn(base.ARGUMENTS_MISSING, six.text_type(exc))
|
self.assertIn(base.ARGUMENTS_MISSING, str(exc))
|
||||||
exc = self.assertRaises(
|
exc = self.assertRaises(
|
||||||
base.CommandException,
|
base.CommandException,
|
||||||
self.openstack, 'resource provider inventory class set fake_uuid')
|
self.openstack, 'resource provider inventory class set fake_uuid')
|
||||||
self.assertIn(base.ARGUMENTS_MISSING, six.text_type(exc))
|
self.assertIn(base.ARGUMENTS_MISSING, str(exc))
|
||||||
exc = self.assertRaises(
|
exc = self.assertRaises(
|
||||||
base.CommandException,
|
base.CommandException,
|
||||||
self.openstack,
|
self.openstack,
|
||||||
('resource provider inventory class set '
|
('resource provider inventory class set '
|
||||||
'fake_uuid fake_class --total 5 --unknown 1'))
|
'fake_uuid fake_class --total 5 --unknown 1'))
|
||||||
self.assertIn('unrecognized arguments', six.text_type(exc))
|
self.assertIn('unrecognized arguments', str(exc))
|
||||||
# Valid RP UUID and resource class, but no inventory field.
|
# Valid RP UUID and resource class, but no inventory field.
|
||||||
rp = self.resource_provider_create()
|
rp = self.resource_provider_create()
|
||||||
exc = self.assertRaises(
|
exc = self.assertRaises(
|
||||||
base.CommandException, self.openstack,
|
base.CommandException, self.openstack,
|
||||||
'resource provider inventory class set %s VCPU' % rp['uuid'])
|
'resource provider inventory class set %s VCPU' % rp['uuid'])
|
||||||
self.assertIn(base.ARGUMENTS_REQUIRED % '--total',
|
self.assertIn(base.ARGUMENTS_REQUIRED % '--total',
|
||||||
six.text_type(exc))
|
str(exc))
|
||||||
|
|
||||||
def test_set_inventory_for_resource_class(self):
|
def test_set_inventory_for_resource_class(self):
|
||||||
rp = self.resource_provider_create()
|
rp = self.resource_provider_create()
|
||||||
|
@ -429,7 +427,7 @@ class TestAggregateInventory(base.BaseTestCase):
|
||||||
'VCPU=8',
|
'VCPU=8',
|
||||||
aggregate=True)
|
aggregate=True)
|
||||||
self.assertIn('No resource providers found in aggregate with uuid {}'
|
self.assertIn('No resource providers found in aggregate with uuid {}'
|
||||||
.format(nonexistent_agg), six.text_type(exc))
|
.format(nonexistent_agg), str(exc))
|
||||||
|
|
||||||
def test_with_aggregate_one_fails(self):
|
def test_with_aggregate_one_fails(self):
|
||||||
# Set up some existing inventories with two resource providers
|
# Set up some existing inventories with two resource providers
|
||||||
|
@ -451,7 +449,7 @@ class TestAggregateInventory(base.BaseTestCase):
|
||||||
self.resource_inventory_set,
|
self.resource_inventory_set,
|
||||||
agg, *new_resources, aggregate=True)
|
agg, *new_resources, aggregate=True)
|
||||||
self.assertIn('Failed to set inventory for 1 of 2 resource providers.',
|
self.assertIn('Failed to set inventory for 1 of 2 resource providers.',
|
||||||
six.text_type(exc))
|
str(exc))
|
||||||
output = self.output.getvalue() + self.error.getvalue()
|
output = self.output.getvalue() + self.error.getvalue()
|
||||||
self.assertIn('Failed to set inventory for resource provider %s:' %
|
self.assertIn('Failed to set inventory for resource provider %s:' %
|
||||||
rp1_uuid, output)
|
rp1_uuid, output)
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
import operator
|
import operator
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from osc_placement.tests.functional import base
|
from osc_placement.tests.functional import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,12 +37,12 @@ class TestResourceProvider(base.BaseTestCase):
|
||||||
self.assertEqual([], after_delete)
|
self.assertEqual([], after_delete)
|
||||||
|
|
||||||
def test_resource_provider_delete_not_found(self):
|
def test_resource_provider_delete_not_found(self):
|
||||||
rp_uuid = six.text_type(uuid.uuid4())
|
rp_uuid = str(uuid.uuid4())
|
||||||
msg = 'No resource provider with uuid ' + rp_uuid + ' found'
|
msg = 'No resource provider with uuid ' + rp_uuid + ' found'
|
||||||
|
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_provider_delete, rp_uuid)
|
self.resource_provider_delete, rp_uuid)
|
||||||
self.assertIn(msg, six.text_type(exc))
|
self.assertIn(msg, str(exc))
|
||||||
|
|
||||||
def test_resource_provider_set(self):
|
def test_resource_provider_set(self):
|
||||||
orig_name = self.rand_name('test_rp_orig_name')
|
orig_name = self.rand_name('test_rp_orig_name')
|
||||||
|
@ -61,12 +59,12 @@ class TestResourceProvider(base.BaseTestCase):
|
||||||
self.assertEqual(0, after_update['generation'])
|
self.assertEqual(0, after_update['generation'])
|
||||||
|
|
||||||
def test_resource_provider_set_not_found(self):
|
def test_resource_provider_set_not_found(self):
|
||||||
rp_uuid = six.text_type(uuid.uuid4())
|
rp_uuid = str(uuid.uuid4())
|
||||||
msg = 'No resource provider with uuid ' + rp_uuid + ' found'
|
msg = 'No resource provider with uuid ' + rp_uuid + ' found'
|
||||||
|
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_provider_set, rp_uuid, 'test')
|
self.resource_provider_set, rp_uuid, 'test')
|
||||||
self.assertIn(msg, six.text_type(exc))
|
self.assertIn(msg, str(exc))
|
||||||
|
|
||||||
def test_resource_provider_show(self):
|
def test_resource_provider_show(self):
|
||||||
created = self.resource_provider_create()
|
created = self.resource_provider_create()
|
||||||
|
@ -99,12 +97,12 @@ class TestResourceProvider(base.BaseTestCase):
|
||||||
self.assertEqual(expected, retrieved)
|
self.assertEqual(expected, retrieved)
|
||||||
|
|
||||||
def test_resource_provider_show_not_found(self):
|
def test_resource_provider_show_not_found(self):
|
||||||
rp_uuid = six.text_type(uuid.uuid4())
|
rp_uuid = str(uuid.uuid4())
|
||||||
msg = 'No resource provider with uuid ' + rp_uuid + ' found'
|
msg = 'No resource provider with uuid ' + rp_uuid + ' found'
|
||||||
|
|
||||||
exc = self.assertRaises(base.CommandException,
|
exc = self.assertRaises(base.CommandException,
|
||||||
self.resource_provider_show, rp_uuid)
|
self.resource_provider_show, rp_uuid)
|
||||||
self.assertIn(msg, six.text_type(exc))
|
self.assertIn(msg, str(exc))
|
||||||
|
|
||||||
def test_resource_provider_list(self):
|
def test_resource_provider_list(self):
|
||||||
rp1 = self.resource_provider_create()
|
rp1 = self.resource_provider_create()
|
||||||
|
@ -256,7 +254,7 @@ class TestResourceProvider114(base.BaseTestCase):
|
||||||
child['uuid'],
|
child['uuid'],
|
||||||
name='mandatory_name_2',
|
name='mandatory_name_2',
|
||||||
parent_provider_uuid=parent2['uuid'])
|
parent_provider_uuid=parent2['uuid'])
|
||||||
self.assertIn('HTTP 400', six.text_type(exc))
|
self.assertIn('HTTP 400', str(exc))
|
||||||
|
|
||||||
def test_resource_provider_list_in_tree(self):
|
def test_resource_provider_list_in_tree(self):
|
||||||
rp1 = self.resource_provider_create()
|
rp1 = self.resource_provider_create()
|
||||||
|
@ -278,7 +276,7 @@ class TestResourceProvider114(base.BaseTestCase):
|
||||||
base.CommandException,
|
base.CommandException,
|
||||||
self.resource_provider_delete,
|
self.resource_provider_delete,
|
||||||
parent['uuid'])
|
parent['uuid'])
|
||||||
self.assertIn('HTTP 409', six.text_type(exc))
|
self.assertIn('HTTP 409', str(exc))
|
||||||
|
|
||||||
|
|
||||||
class TestResourceProvider118(base.BaseTestCase):
|
class TestResourceProvider118(base.BaseTestCase):
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
import operator
|
import operator
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from osc_placement.tests.functional import base
|
from osc_placement.tests.functional import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +50,7 @@ class TestUsage(base.BaseTestCase):
|
||||||
rp_uuid)
|
rp_uuid)
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
'No resource provider with uuid {} found'.format(rp_uuid),
|
'No resource provider with uuid {} found'.format(rp_uuid),
|
||||||
six.text_type(exc)
|
str(exc)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_usage_empty(self):
|
def test_usage_empty(self):
|
||||||
|
|
|
@ -14,7 +14,6 @@ import uuid
|
||||||
|
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from oslotest import base
|
from oslotest import base
|
||||||
import six
|
|
||||||
|
|
||||||
from osc_placement.resources import allocation
|
from osc_placement.resources import allocation
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ class TestAllocation(base.BaseTestCase):
|
||||||
exceptions.CommandError, allocation.parse_allocations, allocations)
|
exceptions.CommandError, allocation.parse_allocations, allocations)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Conflict detected for resource provider %s resource class VCPU' %
|
'Conflict detected for resource provider %s resource class VCPU' %
|
||||||
rp1, six.text_type(ex))
|
rp1, str(ex))
|
||||||
|
|
||||||
def test_fail_if_incorrect_format(self):
|
def test_fail_if_incorrect_format(self):
|
||||||
allocations = ['incorrect_format']
|
allocations = ['incorrect_format']
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
import keystoneauth1.exceptions.http as ks_exceptions
|
import keystoneauth1.exceptions.http as ks_exceptions
|
||||||
import osc_lib.exceptions as exceptions
|
import osc_lib.exceptions as exceptions
|
||||||
import oslotest.base as base
|
import oslotest.base as base
|
||||||
|
@ -54,7 +52,7 @@ class TestSessionClient(base.BaseTestCase):
|
||||||
exc = self.assertRaises(exceptions.NotFound, go)
|
exc = self.assertRaises(exceptions.NotFound, go)
|
||||||
self.assertEqual(404, exc.http_status)
|
self.assertEqual(404, exc.http_status)
|
||||||
self.assertIn('No resource provider with uuid 123 found',
|
self.assertIn('No resource provider with uuid 123 found',
|
||||||
six.text_type(exc))
|
str(exc))
|
||||||
|
|
||||||
def test_unexpected_response(self):
|
def test_unexpected_response(self):
|
||||||
def go():
|
def go():
|
||||||
|
@ -63,7 +61,7 @@ class TestSessionClient(base.BaseTestCase):
|
||||||
|
|
||||||
exc = self.assertRaises(ks_exceptions.InternalServerError, go)
|
exc = self.assertRaises(ks_exceptions.InternalServerError, go)
|
||||||
self.assertEqual(500, exc.http_status)
|
self.assertEqual(500, exc.http_status)
|
||||||
self.assertIn('Internal Server Error (HTTP 500)', six.text_type(exc))
|
self.assertIn('Internal Server Error (HTTP 500)', str(exc))
|
||||||
|
|
||||||
def test_session_client_version(self):
|
def test_session_client_version(self):
|
||||||
session = mock.Mock()
|
session = mock.Mock()
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import oslotest.base as base
|
import oslotest.base as base
|
||||||
import six
|
|
||||||
|
|
||||||
from osc_placement import version
|
from osc_placement import version
|
||||||
|
|
||||||
|
@ -57,13 +56,13 @@ class TestVersion(base.BaseTestCase):
|
||||||
ValueError, version.compare, '1.0', version.ge('1.1'))
|
ValueError, version.compare, '1.0', version.ge('1.1'))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Operation or argument is not supported with version 1.0; '
|
'Operation or argument is not supported with version 1.0; '
|
||||||
'requires at least version 1.1', six.text_type(ex))
|
'requires at least version 1.1', str(ex))
|
||||||
ex = self.assertRaises(
|
ex = self.assertRaises(
|
||||||
ValueError, version.compare, '1.0',
|
ValueError, version.compare, '1.0',
|
||||||
version.eq('1.1'), version.eq('1.5'), op=any)
|
version.eq('1.1'), version.eq('1.5'), op=any)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Operation or argument is not supported with version 1.0; '
|
'Operation or argument is not supported with version 1.0; '
|
||||||
'requires version 1.1, or requires version 1.5', six.text_type(ex))
|
'requires version 1.1, or requires version 1.5', str(ex))
|
||||||
|
|
||||||
def test_compare_with_exc(self):
|
def test_compare_with_exc(self):
|
||||||
self.assertTrue(version.compare('1.05', version.gt('1.4')))
|
self.assertTrue(version.compare('1.05', version.gt('1.4')))
|
||||||
|
|
Loading…
Reference in New Issue