fix indents
rework unit tests

Change-Id: I65a2e749ea863023abea5e6802364c2e85ef0e38
This commit is contained in:
tikitavi 2017-05-25 16:03:31 +03:00
parent 20f65fac2d
commit 169db23ae6
5 changed files with 7 additions and 14 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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}

View File

@ -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)