fix E122 and E126 flake8 issues

Simple indenting for clarity. E122 and E126 are generally pretty
reasonable and not pathologic, so make these cleanups so we can
start enforcing them.

Part of violetprint:travel-day-cleanups

Change-Id: Ie1ff8d31aab83b943784a34702cc5668add68a21
This commit is contained in:
Sean Dague 2013-04-14 15:34:30 -04:00
parent 2416cf3257
commit 14c6818df7
24 changed files with 117 additions and 116 deletions

View File

@ -261,7 +261,7 @@ def bash_openstack(manager,
state.delete_instance_state(kill_id) state.delete_instance_state(kill_id)
for floating_ip_state in state.get_floating_ips(): for floating_ip_state in state.get_floating_ips():
manager.floating_ips_client.delete_floating_ip( manager.floating_ips_client.delete_floating_ip(
floating_ip_state.resource_id) floating_ip_state.resource_id)
for keypair_state in state.get_keypairs(): for keypair_state in state.get_keypairs():
manager.keypairs_client.delete_keypair(keypair_state.name) manager.keypairs_client.delete_keypair(keypair_state.name)
for volume_state in state.get_volumes(): for volume_state in state.get_volumes():

View File

@ -117,8 +117,8 @@ class Client(object):
ready = select.select(*select_params) ready = select.select(*select_params)
if not any(ready): if not any(ready):
raise exceptions.TimeoutException( raise exceptions.TimeoutException(
"Command: '{0}' executed on host '{1}'.".format( "Command: '{0}' executed on host '{1}'.".format(
cmd, self.host)) cmd, self.host))
if not ready[0]: # If there is nothing to read. if not ready[0]: # If there is nothing to read.
continue continue
out_chunk = err_chunk = None out_chunk = err_chunk = None
@ -133,8 +133,8 @@ class Client(object):
exit_status = channel.recv_exit_status() exit_status = channel.recv_exit_status()
if 0 != exit_status: if 0 != exit_status:
raise exceptions.SSHExecCommandFailed( raise exceptions.SSHExecCommandFailed(
command=cmd, exit_status=exit_status, command=cmd, exit_status=exit_status,
strerror=''.join(err_data)) strerror=''.join(err_data))
return ''.join(out_data) return ''.join(out_data)
def test_connection_auth(self): def test_connection_auth(self):

View File

@ -96,7 +96,7 @@ class BotoClientBase(object):
ec2_cred.secret ec2_cred.secret
else: else:
raise exceptions.InvalidConfiguration( raise exceptions.InvalidConfiguration(
"Unable to get access and secret keys") "Unable to get access and secret keys")
return self.connect_method(**self.connection_data) return self.connect_method(**self.connection_data)

View File

@ -31,8 +31,8 @@ class SecurityGroupsClientXML(RestClientXML):
def __init__(self, config, username, password, auth_url, tenant_name=None): def __init__(self, config, username, password, auth_url, tenant_name=None):
super(SecurityGroupsClientXML, self).__init__( super(SecurityGroupsClientXML, self).__init__(
config, username, password, config, username, password,
auth_url, tenant_name) auth_url, tenant_name)
self.service = self.config.compute.catalog_type self.service = self.config.compute.catalog_type
def _parse_array(self, node): def _parse_array(self, node):

View File

@ -152,7 +152,7 @@ class IdentityClientJSON(RestClient):
def enable_disable_user(self, user_id, enabled): def enable_disable_user(self, user_id, enabled):
"""Enables or disables a user.""" """Enables or disables a user."""
put_body = { put_body = {
'enabled': enabled 'enabled': enabled
} }
put_body = json.dumps({'user': put_body}) put_body = json.dumps({'user': put_body})
resp, body = self.put('users/%s/enabled' % user_id, resp, body = self.put('users/%s/enabled' % user_id,

View File

@ -84,7 +84,7 @@ class SnapshotsClientJSON(RestClient):
# state in a "normal" lifecycle # state in a "normal" lifecycle
if (status == 'error'): if (status == 'error'):
raise exceptions.SnapshotBuildErrorException( raise exceptions.SnapshotBuildErrorException(
snapshot_id=snapshot_id) snapshot_id=snapshot_id)
return status return status

View File

@ -93,7 +93,7 @@ class SnapshotsClientXML(RestClientXML):
# state in a "normal" lifecycle # state in a "normal" lifecycle
if (status == 'error'): if (status == 'error'):
raise exceptions.SnapshotBuildErrorException( raise exceptions.SnapshotBuildErrorException(
snapshot_id=snapshot_id) snapshot_id=snapshot_id)
return status return status

View File

@ -443,7 +443,7 @@ class BotoTestCase(tempest.test.BaseTestCase):
return "_GONE" return "_GONE"
except exception.EC2ResponseError as exc: except exception.EC2ResponseError as exc:
if cls.ec2_error_code.\ if cls.ec2_error_code.\
client.InvalidInstanceID.NotFound.match(exc): client.InvalidInstanceID.NotFound.match(exc):
return "_GONE" return "_GONE"
#NOTE(afazekas): incorrect code, #NOTE(afazekas): incorrect code,
# but the resource must be destoreyd # but the resource must be destoreyd

View File

@ -73,8 +73,8 @@ class InstanceRunTest(BotoTestCase):
"location": cls.bucket_name + "/" + ari_manifest}} "location": cls.bucket_name + "/" + ari_manifest}}
for image in cls.images.itervalues(): for image in cls.images.itervalues():
image["image_id"] = cls.ec2_client.register_image( image["image_id"] = cls.ec2_client.register_image(
name=image["name"], name=image["name"],
image_location=image["location"]) image_location=image["location"])
cls.addResourceCleanUp(cls.ec2_client.deregister_image, cls.addResourceCleanUp(cls.ec2_client.deregister_image,
image["image_id"]) image["image_id"])
@ -151,13 +151,15 @@ class InstanceRunTest(BotoTestCase):
group_desc) group_desc)
self.addResourceCleanUp(self.destroy_security_group_wait, self.addResourceCleanUp(self.destroy_security_group_wait,
security_group) security_group)
self.assertTrue(self.ec2_client.authorize_security_group( self.assertTrue(
self.ec2_client.authorize_security_group(
sec_group_name, sec_group_name,
ip_protocol="icmp", ip_protocol="icmp",
cidr_ip="0.0.0.0/0", cidr_ip="0.0.0.0/0",
from_port=-1, from_port=-1,
to_port=-1)) to_port=-1))
self.assertTrue(self.ec2_client.authorize_security_group( self.assertTrue(
self.ec2_client.authorize_security_group(
sec_group_name, sec_group_name,
ip_protocol="tcp", ip_protocol="tcp",
cidr_ip="0.0.0.0/0", cidr_ip="0.0.0.0/0",

View File

@ -63,12 +63,12 @@ class S3ImagesTest(BotoTestCase):
"location": self.bucket_name + "/" + self.ami_manifest, "location": self.bucket_name + "/" + self.ami_manifest,
"type": "ami"} "type": "ami"}
image["image_id"] = self.images_client.register_image( image["image_id"] = self.images_client.register_image(
name=image["name"], name=image["name"],
image_location=image["location"]) image_location=image["location"])
#Note(afazekas): delete_snapshot=True might trigger boto lib? bug #Note(afazekas): delete_snapshot=True might trigger boto lib? bug
image["cleanUp"] = self.addResourceCleanUp( image["cleanUp"] = self.addResourceCleanUp(
self.images_client.deregister_image, self.images_client.deregister_image,
image["image_id"]) image["image_id"])
self.assertEqual(image["image_id"][0:3], image["type"]) self.assertEqual(image["image_id"][0:3], image["type"])
retrieved_image = self.images_client.get_image(image["image_id"]) retrieved_image = self.images_client.get_image(image["image_id"])
self.assertTrue(retrieved_image.name == image["name"]) self.assertTrue(retrieved_image.name == image["name"])
@ -90,11 +90,11 @@ class S3ImagesTest(BotoTestCase):
"location": self.bucket_name + "/" + self.ari_manifest, "location": self.bucket_name + "/" + self.ari_manifest,
"type": "aki"} "type": "aki"}
image["image_id"] = self.images_client.register_image( image["image_id"] = self.images_client.register_image(
name=image["name"], name=image["name"],
image_location=image["location"]) image_location=image["location"])
image["cleanUp"] = self.addResourceCleanUp( image["cleanUp"] = self.addResourceCleanUp(
self.images_client.deregister_image, self.images_client.deregister_image,
image["image_id"]) image["image_id"])
self.assertEqual(image["image_id"][0:3], image["type"]) self.assertEqual(image["image_id"][0:3], image["type"])
retrieved_image = self.images_client.get_image(image["image_id"]) retrieved_image = self.images_client.get_image(image["image_id"])
self.assertTrue(retrieved_image.name == image["name"]) self.assertTrue(retrieved_image.name == image["name"])
@ -115,11 +115,11 @@ class S3ImagesTest(BotoTestCase):
"location": "/" + self.bucket_name + "/" + self.ari_manifest, "location": "/" + self.bucket_name + "/" + self.ari_manifest,
"type": "ari"} "type": "ari"}
image["image_id"] = self.images_client.register_image( image["image_id"] = self.images_client.register_image(
name=image["name"], name=image["name"],
image_location=image["location"]) image_location=image["location"])
image["cleanUp"] = self.addResourceCleanUp( image["cleanUp"] = self.addResourceCleanUp(
self.images_client.deregister_image, self.images_client.deregister_image,
image["image_id"]) image["image_id"])
self.assertEqual(image["image_id"][0:3], image["type"]) self.assertEqual(image["image_id"][0:3], image["type"])
retrieved_image = self.images_client.get_image(image["image_id"]) retrieved_image = self.images_client.get_image(image["image_id"])
self.assertIn(retrieved_image.state, self.valid_image_state) self.assertIn(retrieved_image.state, self.valid_image_state)

View File

@ -92,9 +92,9 @@ class FlavorsExtraSpecsTestJSON(base.BaseComputeAdminTest):
def test_flavor_non_admin_get_keys(self): def test_flavor_non_admin_get_keys(self):
specs = {"key1": "value1", "key2": "value2"} specs = {"key1": "value1", "key2": "value2"}
set_resp, set_body = self.client.set_flavor_extra_spec( set_resp, set_body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs) self.flavor['id'], specs)
resp, body = self.flavors_client.get_flavor_extra_spec( resp, body = self.flavors_client.get_flavor_extra_spec(
self.flavor['id']) self.flavor['id'])
self.assertEqual(resp.status, 200) self.assertEqual(resp.status, 200)
for key in specs: for key in specs:
self.assertEquals(body[key], specs[key]) self.assertEquals(body[key], specs[key])
@ -103,7 +103,7 @@ class FlavorsExtraSpecsTestJSON(base.BaseComputeAdminTest):
def test_flavor_non_admin_unset_keys(self): def test_flavor_non_admin_unset_keys(self):
specs = {"key1": "value1", "key2": "value2"} specs = {"key1": "value1", "key2": "value2"}
set_resp, set_body = self.client.set_flavor_extra_spec( set_resp, set_body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs) self.flavor['id'], specs)
self.assertRaises(exceptions.Unauthorized, self.assertRaises(exceptions.Unauthorized,
self.flavors_client.unset_flavor_extra_spec, self.flavors_client.unset_flavor_extra_spec,

View File

@ -102,14 +102,14 @@ class FloatingIPsTestJSON(base.BaseComputeTest):
# to a specific server should be successful # to a specific server should be successful
#Association of floating IP to fixed IP address #Association of floating IP to fixed IP address
resp, body =\ resp, body = self.client.associate_floating_ip_to_server(
self.client.associate_floating_ip_to_server(self.floating_ip, self.floating_ip,
self.server_id) self.server_id)
self.assertEqual(202, resp.status) self.assertEqual(202, resp.status)
#Disassociation of floating IP that was associated in this method #Disassociation of floating IP that was associated in this method
resp, body = \ resp, body = self.client.disassociate_floating_ip_from_server(
self.client.disassociate_floating_ip_from_server(self.floating_ip, self.floating_ip,
self.server_id) self.server_id)
self.assertEqual(202, resp.status) self.assertEqual(202, resp.status)
@attr(type='negative') @attr(type='negative')
@ -150,13 +150,13 @@ class FloatingIPsTestJSON(base.BaseComputeTest):
self.new_server_id = body['id'] self.new_server_id = body['id']
#Associating floating IP for the first time #Associating floating IP for the first time
resp, _ = \ resp, _ = self.client.associate_floating_ip_to_server(
self.client.associate_floating_ip_to_server(self.floating_ip, self.floating_ip,
self.server_id) self.server_id)
#Associating floating IP for the second time #Associating floating IP for the second time
resp, body = \ resp, body = self.client.associate_floating_ip_to_server(
self.client.associate_floating_ip_to_server(self.floating_ip, self.floating_ip,
self.new_server_id) self.new_server_id)
self.addCleanup(self.servers_client.delete_server, self.new_server_id) self.addCleanup(self.servers_client.delete_server, self.new_server_id)
if (resp['status'] is not None): if (resp['status'] is not None):

View File

@ -57,7 +57,7 @@ class TestServerAdvancedOps(test.DefaultClientSmokeTest):
flavor_id = self.config.compute.flavor_ref flavor_id = self.config.compute.flavor_ref
base_image_id = self.config.compute.image_ref base_image_id = self.config.compute.image_ref
self.instance = self.compute_client.servers.create( self.instance = self.compute_client.servers.create(
i_name, base_image_id, flavor_id) i_name, base_image_id, flavor_id)
try: try:
self.assertEqual(self.instance.name, i_name) self.assertEqual(self.instance.name, i_name)
self.set_resource('instance', self.instance) self.set_resource('instance', self.instance)

View File

@ -78,7 +78,7 @@ class TestServerBasicOps(test.DefaultClientSmokeTest):
for ruleset in rulesets: for ruleset in rulesets:
try: try:
self.compute_client.security_group_rules.create( self.compute_client.security_group_rules.create(
self.secgroup.id, **ruleset) self.secgroup.id, **ruleset)
except Exception: except Exception:
self.fail("Failed to create rule in security group.") self.fail("Failed to create rule in security group.")
@ -90,7 +90,7 @@ class TestServerBasicOps(test.DefaultClientSmokeTest):
'key_name': self.get_resource('keypair').id 'key_name': self.get_resource('keypair').id
} }
self.instance = self.compute_client.servers.create( self.instance = self.compute_client.servers.create(
i_name, base_image_id, flavor_id, **create_kwargs) i_name, base_image_id, flavor_id, **create_kwargs)
try: try:
self.assertEqual(self.instance.name, i_name) self.assertEqual(self.instance.name, i_name)
self.set_resource('instance', self.instance) self.set_resource('instance', self.instance)

View File

@ -43,25 +43,25 @@ class ServerRescueTestJSON(base.BaseComputeTest):
cls.sg_name = rand_name('sg') cls.sg_name = rand_name('sg')
cls.sg_desc = rand_name('sg-desc') cls.sg_desc = rand_name('sg-desc')
resp, cls.sg = \ resp, cls.sg = \
cls.security_groups_client.create_security_group(cls.sg_name, cls.security_groups_client.create_security_group(cls.sg_name,
cls.sg_desc) cls.sg_desc)
cls.sg_id = cls.sg['id'] cls.sg_id = cls.sg['id']
# Create a volume and wait for it to become ready for attach # Create a volume and wait for it to become ready for attach
resp, cls.volume_to_attach = \ resp, cls.volume_to_attach = \
cls.volumes_extensions_client.create_volume(1, cls.volumes_extensions_client.create_volume(1,
display_name= display_name=
'test_attach') 'test_attach')
cls.volumes_extensions_client.wait_for_volume_status( cls.volumes_extensions_client.wait_for_volume_status(
cls.volume_to_attach['id'], 'available') cls.volume_to_attach['id'], 'available')
# Create a volume and wait for it to become ready for attach # Create a volume and wait for it to become ready for attach
resp, cls.volume_to_detach = \ resp, cls.volume_to_detach = \
cls.volumes_extensions_client.create_volume(1, cls.volumes_extensions_client.create_volume(1,
display_name= display_name=
'test_detach') 'test_detach')
cls.volumes_extensions_client.wait_for_volume_status( cls.volumes_extensions_client.wait_for_volume_status(
cls.volume_to_detach['id'], 'available') cls.volume_to_detach['id'], 'available')
# Server for positive tests # Server for positive tests
resp, server = cls.create_server(image_id=cls.image_ref, resp, server = cls.create_server(image_id=cls.image_ref,
@ -93,8 +93,8 @@ class ServerRescueTestJSON(base.BaseComputeTest):
client = cls.volumes_extensions_client client = cls.volumes_extensions_client
client.delete_volume(str(cls.volume_to_attach['id']).strip()) client.delete_volume(str(cls.volume_to_attach['id']).strip())
client.delete_volume(str(cls.volume_to_detach['id']).strip()) client.delete_volume(str(cls.volume_to_detach['id']).strip())
resp, cls.sg = \ resp, cls.sg = cls.security_groups_client.delete_security_group(
cls.security_groups_client.delete_security_group(cls.sg_id) cls.sg_id)
def tearDown(self): def tearDown(self):
super(ServerRescueTestJSON, self).tearDown() super(ServerRescueTestJSON, self).tearDown()
@ -155,7 +155,7 @@ class ServerRescueTestJSON(base.BaseComputeTest):
self.volume_to_detach['id'], self.volume_to_detach['id'],
device='/dev/%s' % self.device) device='/dev/%s' % self.device)
self.volumes_extensions_client.wait_for_volume_status( self.volumes_extensions_client.wait_for_volume_status(
self.volume_to_detach['id'], 'in-use') self.volume_to_detach['id'], 'in-use')
# Rescue the server # Rescue the server
self.servers_client.rescue_server(self.server_id, self.password) self.servers_client.rescue_server(self.server_id, self.password)
@ -181,9 +181,8 @@ class ServerRescueTestJSON(base.BaseComputeTest):
#Association of floating IP to a rescued vm #Association of floating IP to a rescued vm
client = self.floating_ips_client client = self.floating_ips_client
resp, body =\ resp, body = client.associate_floating_ip_to_server(self.floating_ip,
client.associate_floating_ip_to_server(self.floating_ip, self.server_id)
self.server_id)
self.assertEqual(202, resp.status) self.assertEqual(202, resp.status)
#Disassociation of floating IP that was associated in this method #Disassociation of floating IP that was associated in this method

View File

@ -55,9 +55,9 @@ class ServersWhiteboxTest(whitebox.ComputeWhiteboxTest):
def test_create_server_vcpu_quota_full(self): def test_create_server_vcpu_quota_full(self):
# Disallow server creation when tenant's vcpu quota is full # Disallow server creation when tenant's vcpu quota is full
quotas = self.meta.tables['quotas'] quotas = self.meta.tables['quotas']
stmt = quotas.select().where( stmt = (quotas.select().
quotas.c.project_id == self.tenant_id).where( where(quotas.c.project_id == self.tenant_id).
quotas.c.resource == 'cores') where(quotas.c.resource == 'cores'))
result = self.connection.execute(stmt).first() result = self.connection.execute(stmt).first()
# Set vcpu quota for tenant if not already set # Set vcpu quota for tenant if not already set
@ -87,9 +87,9 @@ class ServersWhiteboxTest(whitebox.ComputeWhiteboxTest):
def test_create_server_memory_quota_full(self): def test_create_server_memory_quota_full(self):
# Disallow server creation when tenant's memory quota is full # Disallow server creation when tenant's memory quota is full
quotas = self.meta.tables['quotas'] quotas = self.meta.tables['quotas']
stmt = quotas.select().where( stmt = (quotas.select().
quotas.c.project_id == self.tenant_id).where( where(quotas.c.project_id == self.tenant_id).
quotas.c.resource == 'ram') where(quotas.c.resource == 'ram'))
result = self.connection.execute(stmt).first() result = self.connection.execute(stmt).first()
# Set memory quota for tenant if not already set # Set memory quota for tenant if not already set

View File

@ -89,9 +89,9 @@ class CreateRegisterImagesTest(base.BaseV1ImageTest):
self.addCleanup(container_client.delete_container, container_name) self.addCleanup(container_client.delete_container, container_name)
cont_headers = {'X-Container-Read': '.r:*'} cont_headers = {'X-Container-Read': '.r:*'}
resp, _ = container_client.update_container_metadata( resp, _ = container_client.update_container_metadata(
container_name, container_name,
metadata=cont_headers, metadata=cont_headers,
metadata_prefix='') metadata_prefix='')
self.assertEqual(resp['status'], '204') self.assertEqual(resp['status'], '204')
data = "TESTIMAGE" data = "TESTIMAGE"
@ -270,7 +270,7 @@ class ListImagesTest(base.BaseV1ImageTest):
@attr(type='image') @attr(type='image')
def test_index_name(self): def test_index_name(self):
resp, images_list = self.client.image_list_detail( resp, images_list = self.client.image_list_detail(
name='New Remote Image dup') name='New Remote Image dup')
self.assertEqual(resp['status'], '200') self.assertEqual(resp['status'], '200')
result_set = set(map(lambda x: x['id'], images_list)) result_set = set(map(lambda x: x['id'], images_list))
for image in images_list: for image in images_list:

View File

@ -124,7 +124,7 @@ class ContainerTest(base.BaseObjectTest):
# List container metadata # List container metadata
resp, _ = self.container_client.list_container_metadata( resp, _ = self.container_client.list_container_metadata(
container_name) container_name)
self.assertEqual(resp['status'], '204') self.assertEqual(resp['status'], '204')
self.assertIn('x-container-meta-name', resp) self.assertIn('x-container-meta-name', resp)
self.assertIn('x-container-meta-description', resp) self.assertIn('x-container-meta-description', resp)
@ -132,10 +132,9 @@ class ContainerTest(base.BaseObjectTest):
self.assertEqual(resp['x-container-meta-description'], 'Travel') self.assertEqual(resp['x-container-meta-description'], 'Travel')
# Delete container metadata # Delete container metadata
resp, _ = \ resp, _ = self.container_client.delete_container_metadata(
self.container_client.delete_container_metadata( container_name,
container_name, metadata=metadata.keys())
metadata=metadata.keys())
self.assertEqual(resp['status'], '204') self.assertEqual(resp['status'], '204')
resp, _ = self.container_client.list_container_metadata(container_name) resp, _ = self.container_client.list_container_metadata(container_name)

View File

@ -59,7 +59,7 @@ class ContainerTest(base.BaseObjectTest):
# Create a containers # Create a containers
vers_container_name = rand_name(name='TestVersionContainer') vers_container_name = rand_name(name='TestVersionContainer')
resp, body = self.container_client.create_container( resp, body = self.container_client.create_container(
vers_container_name) vers_container_name)
self.containers.append(vers_container_name) self.containers.append(vers_container_name)
self.assertIn(resp['status'], ('202', '201')) self.assertIn(resp['status'], ('202', '201'))
self.assertContainer(vers_container_name, '0', '0', self.assertContainer(vers_container_name, '0', '0',
@ -68,9 +68,9 @@ class ContainerTest(base.BaseObjectTest):
base_container_name = rand_name(name='TestBaseContainer') base_container_name = rand_name(name='TestBaseContainer')
headers = {'X-versions-Location': vers_container_name} headers = {'X-versions-Location': vers_container_name}
resp, body = self.container_client.create_container( resp, body = self.container_client.create_container(
base_container_name, base_container_name,
metadata=headers, metadata=headers,
metadata_prefix='') metadata_prefix='')
self.containers.append(base_container_name) self.containers.append(base_container_name)
self.assertIn(resp['status'], ('202', '201')) self.assertIn(resp['status'], ('202', '201'))
self.assertContainer(base_container_name, '0', '0', self.assertContainer(base_container_name, '0', '0',

View File

@ -55,15 +55,15 @@ class VolumeTypesTest(BaseVolumeTest):
extra_specs = {"storage_protocol": "iSCSI", extra_specs = {"storage_protocol": "iSCSI",
"vendor_name": "Open Source"} "vendor_name": "Open Source"}
body = {} body = {}
resp, body = self.client.create_volume_type(vol_type_name, resp, body = self.client.create_volume_type(
extra_specs= vol_type_name,
extra_specs) extra_specs=extra_specs)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertTrue('id' in body) self.assertTrue('id' in body)
self.assertTrue('name' in body) self.assertTrue('name' in body)
resp, volume = self.volumes_client.\ resp, volume = self.volumes_client.create_volume(
create_volume(size=1, display_name=vol_name, size=1, display_name=vol_name,
volume_type=vol_type_name) volume_type=vol_type_name)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertTrue('id' in volume) self.assertTrue('id' in volume)
self.assertTrue('display_name' in volume) self.assertTrue('display_name' in volume)
@ -74,8 +74,7 @@ class VolumeTypesTest(BaseVolumeTest):
"Field volume id is empty or not found.") "Field volume id is empty or not found.")
self.volumes_client.wait_for_volume_status(volume['id'], self.volumes_client.wait_for_volume_status(volume['id'],
'available') 'available')
resp, fetched_volume = self.volumes_client.\ resp, fetched_volume = self.volumes_client.get_volume(volume['id'])
get_volume(volume['id'])
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertEqual(vol_name, fetched_volume['display_name'], self.assertEqual(vol_name, fetched_volume['display_name'],
'The fetched Volume is different ' 'The fetched Volume is different '
@ -104,8 +103,9 @@ class VolumeTypesTest(BaseVolumeTest):
name = rand_name("volume-type-") name = rand_name("volume-type-")
extra_specs = {"storage_protocol": "iSCSI", extra_specs = {"storage_protocol": "iSCSI",
"vendor_name": "Open Source"} "vendor_name": "Open Source"}
resp, body = self.client.\ resp, body = self.client.create_volume_type(
create_volume_type(name, extra_specs=extra_specs) name,
extra_specs=extra_specs)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertTrue('id' in body) self.assertTrue('id' in body)
self.assertTrue('name' in body) self.assertTrue('name' in body)
@ -114,8 +114,7 @@ class VolumeTypesTest(BaseVolumeTest):
"to the requested name") "to the requested name")
self.assertTrue(body['id'] is not None, self.assertTrue(body['id'] is not None,
"Field volume_type id is empty or not found.") "Field volume_type id is empty or not found.")
resp, fetched_volume_type = self.client.\ resp, _ = self.client.delete_volume_type(body['id'])
delete_volume_type(body['id'])
self.assertEqual(202, resp.status) self.assertEqual(202, resp.status)
except Exception: except Exception:
self.fail("Could not create a volume_type") self.fail("Could not create a volume_type")
@ -127,8 +126,9 @@ class VolumeTypesTest(BaseVolumeTest):
name = rand_name("volume-type-") name = rand_name("volume-type-")
extra_specs = {"storage_protocol": "iSCSI", extra_specs = {"storage_protocol": "iSCSI",
"vendor_name": "Open Source"} "vendor_name": "Open Source"}
resp, body = self.client.\ resp, body = self.client.create_volume_type(
create_volume_type(name, extra_specs=extra_specs) name,
extra_specs=extra_specs)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertTrue('id' in body) self.assertTrue('id' in body)
self.assertTrue('name' in body) self.assertTrue('name' in body)

View File

@ -37,13 +37,13 @@ class VolumeTypesExtraSpecsTest(base.BaseVolumeAdminTest):
# List Volume types extra specs. # List Volume types extra specs.
try: try:
extra_specs = {"spec1": "val1"} extra_specs = {"spec1": "val1"}
resp, body = self.client.\ resp, body = self.client.create_volume_type_extra_specs(
create_volume_type_extra_specs(self.volume_type['id'], extra_specs) self.volume_type['id'], extra_specs)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body, self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created") "Volume type extra spec incorrectly created")
resp, body = self.client.\ resp, body = self.client.list_volume_types_extra_specs(
list_volume_types_extra_specs(self.volume_type['id']) self.volume_type['id'])
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertTrue(type(body), dict) self.assertTrue(type(body), dict)
self.assertTrue('spec1' in body, "Incorrect volume type extra" self.assertTrue('spec1' in body, "Incorrect volume type extra"
@ -55,17 +55,17 @@ class VolumeTypesExtraSpecsTest(base.BaseVolumeAdminTest):
# Update volume type extra specs # Update volume type extra specs
try: try:
extra_specs = {"spec2": "val1"} extra_specs = {"spec2": "val1"}
resp, body = self.client.\ resp, body = self.client.create_volume_type_extra_specs(
create_volume_type_extra_specs(self.volume_type['id'], extra_specs) self.volume_type['id'], extra_specs)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body, self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created") "Volume type extra spec incorrectly created")
extra_spec = {"spec2": "val2"} extra_spec = {"spec2": "val2"}
resp, body = self.client.\ resp, body = self.client.update_volume_type_extra_specs(
update_volume_type_extra_specs(self.volume_type['id'], self.volume_type['id'],
extra_spec.keys()[0], extra_spec.keys()[0],
extra_spec) extra_spec)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertTrue('spec2' in body, self.assertTrue('spec2' in body,
"Volume type extra spec incorrectly updated") "Volume type extra spec incorrectly updated")
@ -78,22 +78,23 @@ class VolumeTypesExtraSpecsTest(base.BaseVolumeAdminTest):
# Create/Get/Delete volume type extra spec. # Create/Get/Delete volume type extra spec.
try: try:
extra_specs = {"spec3": "val1"} extra_specs = {"spec3": "val1"}
resp, body = self.client.\ resp, body = self.client.create_volume_type_extra_specs(
create_volume_type_extra_specs(self.volume_type['id'], extra_specs) self.volume_type['id'],
extra_specs)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body, self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created") "Volume type extra spec incorrectly created")
resp, fetched_vol_type_extra_spec = self.client.\ resp, _ = self.client.get_volume_type_extra_specs(
get_volume_type_extra_specs(self.volume_type['id'], self.volume_type['id'],
extra_specs.keys()[0]) extra_specs.keys()[0])
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body, self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly fetched") "Volume type extra spec incorrectly fetched")
resp, _ = self.client.\ resp, _ = self.client.delete_volume_type_extra_specs(
delete_volume_type_extra_specs(self.volume_type['id'], self.volume_type['id'],
extra_specs.keys()[0]) extra_specs.keys()[0])
self.assertEqual(202, resp.status) self.assertEqual(202, resp.status)
except Exception: except Exception:
self.fail("Could not create a volume_type extra spec") self.fail("Could not create a volume_type extra spec")

View File

@ -111,7 +111,7 @@ class ComputeWhiteboxTest(test.ComputeFuzzClientTest, WhiteboxTest):
image_id = cls.image_ref image_id = cls.image_ref
resp, server = cls.servers_client.create_server( resp, server = cls.servers_client.create_server(
server_name, image_id, flavor) server_name, image_id, flavor)
cls.servers_client.wait_for_server_status(server['id'], 'ACTIVE') cls.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
cls.servers.append(server) cls.servers.append(server)
return server return server

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
flake8 --ignore=E122,E125,E126,H302,H304,H404,F --show-source --exclude=.git,.venv,.tox,dist,doc,openstack,*egg . flake8 --ignore=E125,H302,H304,H404,F --show-source --exclude=.git,.venv,.tox,dist,doc,openstack,*egg .
pep8_ret=$? pep8_ret=$?
pyflakes tempest stress setup.py tools cli bin | grep "imported but unused" pyflakes tempest stress setup.py tools cli bin | grep "imported but unused"

View File

@ -165,7 +165,7 @@ def main(argv):
resp, body = coverage_client.report_coverage_xml(file=CLI.filename) resp, body = coverage_client.report_coverage_xml(file=CLI.filename)
elif CLI.html: elif CLI.html:
resp, body = coverage_client.report_coverage_html( resp, body = coverage_client.report_coverage_html(
file=CLI.filename) file=CLI.filename)
else: else:
resp, body = coverage_client.report_coverage(file=CLI.filename) resp, body = coverage_client.report_coverage(file=CLI.filename)
if not resp['status'] == '200': if not resp['status'] == '200':