From 169db23ae65a970967800ad5aaeb2750307bef2f Mon Sep 17 00:00:00 2001 From: tikitavi Date: Thu, 25 May 2017 16:03:31 +0300 Subject: [PATCH] minor fix to https://review.openstack.org/#/c/466115/ fix indents rework unit tests Change-Id: I65a2e749ea863023abea5e6802364c2e85ef0e38 --- ec2api/api/address.py | 12 +++++------- ec2api/tests/unit/test_availability_zone.py | 1 - ec2api/tests/unit/test_instance.py | 5 +---- ec2api/tests/unit/test_metadata.py | 2 +- ec2api/tests/unit/test_security_group.py | 1 - 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/ec2api/api/address.py b/ec2api/api/address.py index 9296b0f2..a1b2bfa9 100644 --- a/ec2api/api/address.py +++ b/ec2api/api/address.py @@ -195,15 +195,14 @@ def _disassociate_address_item(context, address): db_api.update_item(context, address) -def _get_os_instance_id(context, os_floating_ip, - os_ports=[]): +def _get_os_instance_id(context, os_floating_ip, os_ports=[]): port_id = os_floating_ip.get('port_id') os_instance_id = None if port_id: port = next((port for port in os_ports if port['id'] == port_id), None) - if port and port.get('device_id'): - os_instance_id = port['device_id'] + if port: + os_instance_id = port.get('device_id') return os_instance_id @@ -402,11 +401,10 @@ class AddressEngineNeutron(object): # NOTE(tikitavi): check the public IP exists to raise AWS # exception otherwise os_floating_ip = self.get_os_floating_ip_by_public_ip( - context, - public_ip) + context, public_ip) os_ports = self.get_os_ports(context) os_instance_id = _get_os_instance_id(context, os_floating_ip, - os_ports) + os_ports) if os_instance_id: nova = clients.nova(context) nova.servers.remove_floating_ip(os_instance_id, public_ip) diff --git a/ec2api/tests/unit/test_availability_zone.py b/ec2api/tests/unit/test_availability_zone.py index 1f399053..da315aa4 100644 --- a/ec2api/tests/unit/test_availability_zone.py +++ b/ec2api/tests/unit/test_availability_zone.py @@ -54,7 +54,6 @@ class AvailabilityZoneCase(base.ApiTestCase): self.assertTrue(resp['regionInfo'][0].get('regionEndpoint') is not None) - # TODO(tikitavi): Rework test to exclude nova-network @mock.patch('ec2api.api.ec2utils.check_and_create_default_vpc') def test_describe_account_attributes(self, check_and_create): self.nova.quotas.get.return_value = mock.Mock(instances=77) diff --git a/ec2api/tests/unit/test_instance.py b/ec2api/tests/unit/test_instance.py index 928efdac..524023d4 100644 --- a/ec2api/tests/unit/test_instance.py +++ b/ec2api/tests/unit/test_instance.py @@ -848,10 +848,7 @@ class InstanceTestCase(base.ApiTestCase): 'DescribeInstances', ['reservationSet', 'instancesSet'], fakes.ID_EC2_INSTANCE_1, 'instanceId') - # TODO(tikitavi): Rework test to exclude nova-network - def _test_describe_instances_ec2_classic(self): - instance_api.instance_engine = ( - instance_api.InstanceEngineNova()) + def test_describe_instances_ec2_classic(self): self.set_mock_db_items( fakes.DB_INSTANCE_2, fakes.DB_IMAGE_1, fakes.DB_IMAGE_2, fakes.DB_VOLUME_1, fakes.DB_VOLUME_2, fakes.DB_VOLUME_3) diff --git a/ec2api/tests/unit/test_metadata.py b/ec2api/tests/unit/test_metadata.py index bd02d1d2..31d5b074 100644 --- a/ec2api/tests/unit/test_metadata.py +++ b/ec2api/tests/unit/test_metadata.py @@ -92,7 +92,7 @@ class ProxyTestCase(test_base.BaseTestCase): self.assertEqual(500, response.status_int) self.assertEqual(len(log.mock_calls), 2) - def _test_get_requester(self): + def test_get_requester(self): expected = {'os_instance_id': mock.sentinel.os_instance_id, 'project_id': mock.sentinel.project_id, 'private_ip': mock.sentinel.private_ip} diff --git a/ec2api/tests/unit/test_security_group.py b/ec2api/tests/unit/test_security_group.py index cd0c3c49..c8976082 100644 --- a/ec2api/tests/unit/test_security_group.py +++ b/ec2api/tests/unit/test_security_group.py @@ -163,7 +163,6 @@ class SecurityGroupTestCase(base.ApiTestCase): self.neutron.create_security_group.assert_called_once_with( secgroup_body) - # TODO(tikitavi): Rework test to exclude nova-network @tools.screen_unexpected_exception_logs def test_create_security_group_rollback(self): self.set_mock_db_items(fakes.DB_VPC_1)