Best Python code snippet using tempest_python
test_address.py
Source:test_address.py
1# Copyright 20142# The Cloudscaling Group, Inc.3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14import mock15from neutronclient.common import exceptions as neutron_exception16from novaclient import exceptions as nova_exception17from ec2api.api import address18from ec2api.tests.unit import base19from ec2api.tests.unit import fakes20from ec2api.tests.unit import matchers21from ec2api.tests.unit import tools22class AddressTestCase(base.ApiTestCase):23 def test_allocate_ec2_classic_address(self):24 address.address_engine = (25 address.AddressEngineNeutron())26 self.nova.floating_ips.create.return_value = (27 fakes.NovaFloatingIp(fakes.NOVA_FLOATING_IP_1))28 resp = self.execute('AllocateAddress', {})29 self.assertEqual(fakes.IP_ADDRESS_1, resp['publicIp'])30 self.assertEqual('standard', resp['domain'])31 self.assertNotIn('allocationId', resp)32 self.assertEqual(0, self.db_api.add_item.call_count)33 self.nova.floating_ips.create.assert_called_once_with()34 def test_allocate_vpc_address(self):35 address.address_engine = (36 address.AddressEngineNeutron())37 self.configure(external_network=fakes.NAME_OS_PUBLIC_NETWORK)38 self.neutron.list_networks.return_value = (39 {'networks': [{'id': fakes.ID_OS_PUBLIC_NETWORK}]})40 self.neutron.create_floatingip.return_value = (41 {'floatingip': fakes.OS_FLOATING_IP_1})42 self.db_api.add_item.return_value = fakes.DB_ADDRESS_143 resp = self.execute('AllocateAddress', {'Domain': 'vpc'})44 self.assertEqual(fakes.IP_ADDRESS_1, resp['publicIp'])45 self.assertEqual('vpc', resp['domain'])46 self.assertEqual(fakes.ID_EC2_ADDRESS_1,47 resp['allocationId'])48 self.db_api.add_item.assert_called_once_with(49 mock.ANY, 'eipalloc',50 tools.purge_dict(fakes.DB_ADDRESS_1,51 ('id', 'vpc_id')),52 project_id=None)53 self.neutron.create_floatingip.assert_called_once_with(54 {'floatingip': {55 'floating_network_id':56 fakes.ID_OS_PUBLIC_NETWORK}})57 self.neutron.list_networks.assert_called_once_with(58 **{'router:external': True,59 'name': fakes.NAME_OS_PUBLIC_NETWORK})60 def test_allocate_address_invalid_parameters(self):61 address.address_engine = (62 address.AddressEngineNeutron())63 self.assert_execution_error('InvalidParameterValue', 'AllocateAddress',64 {'Domain': 'fake_domain'})65 self.assertEqual(0, self.db_api.add_item.call_count)66 self.assertEqual(0, self.neutron.create_floatingip.call_count)67 def test_allocate_address_overlimit(self):68 address.address_engine = (69 address.AddressEngineNeutron())70 self.configure(external_network=fakes.NAME_OS_PUBLIC_NETWORK)71 self.neutron.list_networks.return_value = (72 {'networks': [{'id': fakes.ID_OS_PUBLIC_NETWORK}]})73 self.neutron.create_floatingip.side_effect = (74 neutron_exception.OverQuotaClient())75 self.assert_execution_error('AddressLimitExceeded', 'AllocateAddress',76 {'Domain': 'vpc'})77 address.address_engine = (78 address.AddressEngineNeutron())79 self.nova.floating_ips.create.side_effect = (80 nova_exception.Forbidden(403))81 self.assert_execution_error('AddressLimitExceeded', 'AllocateAddress',82 {})83 @tools.screen_unexpected_exception_logs84 def test_allocate_address_vpc_rollback(self):85 address.address_engine = (86 address.AddressEngineNeutron())87 self.configure(external_network=fakes.NAME_OS_PUBLIC_NETWORK)88 self.neutron.list_networks.return_value = (89 {'networks': [{'id': fakes.ID_OS_PUBLIC_NETWORK}]})90 self.neutron.create_floatingip.return_value = (91 {'floatingip': fakes.OS_FLOATING_IP_1})92 self.db_api.add_item.side_effect = Exception()93 self.assert_execution_error(self.ANY_EXECUTE_ERROR, 'AllocateAddress',94 {'Domain': 'vpc'})95 self.neutron.delete_floatingip.assert_called_once_with(96 fakes.ID_OS_FLOATING_IP_1)97 def test_associate_address_ec2_classic(self):98 address.address_engine = (99 address.AddressEngineNeutron())100 self.set_mock_db_items(fakes.DB_INSTANCE_1)101 self.nova.floating_ips.list.return_value = (102 [fakes.NovaFloatingIp(fakes.NOVA_FLOATING_IP_1),103 fakes.NovaFloatingIp(fakes.NOVA_FLOATING_IP_2)])104 self.nova.servers.add_floating_ip.return_value = True105 resp = self.execute('AssociateAddress',106 {'PublicIp': fakes.IP_ADDRESS_1,107 'InstanceId': fakes.ID_EC2_INSTANCE_1})108 self.assertEqual(True, resp['return'])109 self.nova.servers.add_floating_ip.assert_called_once_with(110 fakes.ID_OS_INSTANCE_1,111 fakes.IP_ADDRESS_1)112 def test_associate_address_vpc(self):113 address.address_engine = (114 address.AddressEngineNeutron())115 def do_check(params, fixed_ip):116 resp = self.execute('AssociateAddress', params)117 self.assertEqual(True, resp['return'])118 self.assertEqual(fakes.ID_EC2_ASSOCIATION_1, resp['associationId'])119 self.neutron.update_floatingip.assert_called_once_with(120 fakes.ID_OS_FLOATING_IP_1,121 {'floatingip': {'port_id': fakes.ID_OS_PORT_2,122 'fixed_ip_address': fixed_ip}})123 self.db_api.update_item.assert_called_once_with(124 mock.ANY,125 tools.update_dict(126 fakes.DB_ADDRESS_1,127 {'network_interface_id':128 fakes.ID_EC2_NETWORK_INTERFACE_2,129 'private_ip_address': fixed_ip}))130 self.neutron.update_floatingip.reset_mock()131 self.db_api.update_item.reset_mock()132 self.set_mock_db_items(133 fakes.DB_ADDRESS_1, fakes.DB_IGW_1, fakes.DB_IGW_2,134 fakes.DB_NETWORK_INTERFACE_1, fakes.DB_NETWORK_INTERFACE_2)135 self.neutron.show_floatingip.return_value = (136 {'floatingip': fakes.OS_FLOATING_IP_1})137 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1,138 'InstanceId': fakes.ID_EC2_INSTANCE_1},139 fakes.IP_NETWORK_INTERFACE_2)140 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1,141 'NetworkInterfaceId': fakes.ID_EC2_NETWORK_INTERFACE_2},142 fakes.IP_NETWORK_INTERFACE_2)143 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1,144 'NetworkInterfaceId': fakes.ID_EC2_NETWORK_INTERFACE_2,145 'PrivateIpAddress': fakes.IP_NETWORK_INTERFACE_2_EXT_1},146 fakes.IP_NETWORK_INTERFACE_2_EXT_1)147 assigned_db_address_1 = tools.update_dict(148 fakes.DB_ADDRESS_1,149 {'network_interface_id': fakes.ID_EC2_NETWORK_INTERFACE_1,150 'private_ip_address': fakes.IP_NETWORK_INTERFACE_1})151 self.add_mock_db_items(assigned_db_address_1)152 assigned_floating_ip_1 = tools.update_dict(153 fakes.OS_FLOATING_IP_1,154 {'fixed_port_id': fakes.ID_OS_PORT_1,155 'fixed_ip_address': fakes.IP_NETWORK_INTERFACE_1})156 self.neutron.show_floatingip.return_value = (157 {'floatingip': assigned_floating_ip_1})158 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1,159 'InstanceId': fakes.ID_EC2_INSTANCE_1,160 'AllowReassociation': 'True'},161 fakes.IP_NETWORK_INTERFACE_2)162 def test_associate_address_vpc_idempotent(self):163 address.address_engine = (164 address.AddressEngineNeutron())165 def do_check(params):166 resp = self.execute('AssociateAddress', params)167 self.assertEqual(True, resp['return'])168 self.assertEqual(fakes.ID_EC2_ASSOCIATION_2, resp['associationId'])169 self.set_mock_db_items(fakes.DB_ADDRESS_2,170 fakes.DB_NETWORK_INTERFACE_1,171 fakes.DB_NETWORK_INTERFACE_2)172 self.neutron.show_floatingip.return_value = (173 {'floatingip': fakes.OS_FLOATING_IP_2})174 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_2,175 'InstanceId': fakes.ID_EC2_INSTANCE_1})176 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_2,177 'NetworkInterfaceId': fakes.ID_EC2_NETWORK_INTERFACE_2})178 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_2,179 'NetworkInterfaceId': fakes.ID_EC2_NETWORK_INTERFACE_2,180 'PrivateIpAddress': fakes.IP_NETWORK_INTERFACE_2})181 def test_associate_address_invalid_main_parameters(self):182 address.address_engine = (183 address.AddressEngineNeutron())184 def do_check(params, error):185 self.assert_execution_error(error, 'AssociateAddress', params)186 do_check({},187 'MissingParameter')188 do_check({'PublicIp': '0.0.0.0',189 'AllocationId': 'eipalloc-0'},190 'InvalidParameterCombination')191 do_check({'PublicIp': '0.0.0.0'},192 'MissingParameter')193 do_check({'AllocationId': 'eipalloc-0'},194 'MissingParameter')195 def test_associate_address_invalid_ec2_classic_parameters(self):196 address.address_engine = (197 address.AddressEngineNeutron())198 # NOTE(ft): ec2 classic instance vs allocation_id parameter199 self.set_mock_db_items(fakes.DB_INSTANCE_2)200 self.assert_execution_error('InvalidParameterCombination',201 'AssociateAddress',202 {'AllocationId': 'eipalloc-0',203 'InstanceId': fakes.ID_EC2_INSTANCE_2})204 # NOTE(ft): ec2 classic instance vs not existing public IP205 self.nova.floating_ips.list.return_value = []206 self.assert_execution_error('AuthFailure', 'AssociateAddress',207 {'PublicIp': fakes.IP_ADDRESS_1,208 'InstanceId': fakes.ID_EC2_INSTANCE_2})209 # NOTE(ft): ec2 classic instance vs vpc public ip210 self.add_mock_db_items(fakes.DB_ADDRESS_1, fakes.DB_ADDRESS_2)211 self.neutron.show_floatingip.return_value = (212 {'floatingip': fakes.OS_FLOATING_IP_1})213 self.assert_execution_error('AuthFailure', 'AssociateAddress',214 {'PublicIp': fakes.IP_ADDRESS_1,215 'InstanceId': fakes.ID_EC2_INSTANCE_2})216 def test_associate_address_invalid_vpc_parameters(self):217 address.address_engine = (218 address.AddressEngineNeutron())219 def do_check(params, error):220 self.assert_execution_error(error, 'AssociateAddress', params)221 # NOTE(ft): not registered instance id vs vpc address222 self.set_mock_db_items()223 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1,224 'InstanceId': fakes.ID_EC2_INSTANCE_1},225 'InvalidInstanceID.NotFound')226 # NOTE(ft): vpc instance vs public ip parmeter227 self.set_mock_db_items(fakes.DB_NETWORK_INTERFACE_2)228 do_check({'PublicIp': '0.0.0.0',229 'InstanceId': fakes.ID_EC2_INSTANCE_1},230 'InvalidParameterCombination')231 # NOTE(ft): vpc instance vs not registered vpc address232 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1,233 'InstanceId': fakes.ID_EC2_INSTANCE_1},234 'InvalidAllocationID.NotFound')235 # NOTE(ft): not registered network interface id vs vpc address236 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1,237 'NetworkInterfaceId': fakes.ID_EC2_NETWORK_INTERFACE_1},238 'InvalidNetworkInterfaceID.NotFound')239 # NOTE(ft): vpc instance vs broken vpc address240 self.set_mock_db_items(fakes.DB_ADDRESS_1,241 fakes.DB_NETWORK_INTERFACE_2)242 self.neutron.show_floatingip.side_effect = neutron_exception.NotFound243 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1,244 'InstanceId': fakes.ID_EC2_INSTANCE_1},245 'InvalidAllocationID.NotFound')246 self.neutron.show_floatingip.side_effect = None247 # NOTE(ft): already associated address vs network interface248 self.set_mock_db_items(fakes.DB_ADDRESS_1, fakes.DB_ADDRESS_2,249 fakes.DB_NETWORK_INTERFACE_1)250 self.neutron.show_floatingip.return_value = (251 {'floatingip': fakes.OS_FLOATING_IP_2})252 self.assert_execution_error(253 'Resource.AlreadyAssociated', 'AssociateAddress',254 {'AllocationId': fakes.ID_EC2_ADDRESS_2,255 'NetworkInterfaceId': fakes.ID_EC2_NETWORK_INTERFACE_1})256 # NOTE(ft): already associated address vs vpc instance257 self.set_mock_db_items(258 fakes.DB_ADDRESS_2,259 fakes.gen_db_network_interface(260 fakes.ID_EC2_NETWORK_INTERFACE_1,261 fakes.ID_OS_PORT_1,262 fakes.ID_EC2_VPC_1,263 fakes.ID_EC2_SUBNET_1,264 fakes.IP_NETWORK_INTERFACE_1,265 instance_id=fakes.ID_EC2_INSTANCE_1))266 self.assert_execution_error('Resource.AlreadyAssociated',267 'AssociateAddress',268 {'AllocationId': fakes.ID_EC2_ADDRESS_2,269 'InstanceId': fakes.ID_EC2_INSTANCE_1})270 # NOTE(ft): multiple network interfaces in vpc instance271 # w/o network interface selection272 self.add_mock_db_items(fakes.DB_NETWORK_INTERFACE_2)273 self.assert_execution_error('InvalidInstanceID', 'AssociateAddress',274 {'AllocationId': fakes.ID_EC2_ADDRESS_1,275 'InstanceId': fakes.ID_EC2_INSTANCE_1})276 # NOTE(ft): internet gateway isn't attached to the vpc277 self.set_mock_db_items(fakes.DB_ADDRESS_1,278 fakes.DB_NETWORK_INTERFACE_2)279 self.assert_execution_error('Gateway.NotAttached', 'AssociateAddress',280 {'AllocationId': fakes.ID_EC2_ADDRESS_1,281 'InstanceId': fakes.ID_EC2_INSTANCE_1})282 @tools.screen_unexpected_exception_logs283 def test_associate_address_vpc_rollback(self):284 address.address_engine = (285 address.AddressEngineNeutron())286 self.set_mock_db_items(fakes.DB_ADDRESS_1, fakes.DB_IGW_1,287 fakes.DB_NETWORK_INTERFACE_1,288 fakes.DB_NETWORK_INTERFACE_2)289 self.neutron.show_floatingip.return_value = (290 {'floatingip': fakes.OS_FLOATING_IP_1})291 self.neutron.update_floatingip.side_effect = Exception()292 self.assert_execution_error(self.ANY_EXECUTE_ERROR, 'AssociateAddress',293 {'AllocationId': fakes.ID_EC2_ADDRESS_1,294 'InstanceId': fakes.ID_EC2_INSTANCE_1})295 self.db_api.update_item.assert_any_call(296 mock.ANY, fakes.DB_ADDRESS_1)297 def test_dissassociate_address_ec2_classic(self):298 address.address_engine = (299 address.AddressEngineNeutron())300 self.set_mock_db_items()301 self.nova.servers.remove_floating_ip.return_value = True302 self.nova.floating_ips.list.return_value = (303 [fakes.NovaFloatingIp(fakes.NOVA_FLOATING_IP_1),304 fakes.NovaFloatingIp(fakes.NOVA_FLOATING_IP_2)])305 resp = self.execute('DisassociateAddress',306 {'PublicIp': fakes.IP_ADDRESS_2})307 self.assertEqual(True, resp['return'])308 self.nova.servers.remove_floating_ip.assert_called_once_with(309 fakes.ID_OS_INSTANCE_1,310 fakes.IP_ADDRESS_2)311 # NOTE(Alex) Disassociate unassociated address in EC2 classic312 resp = self.execute('DisassociateAddress',313 {'PublicIp': fakes.IP_ADDRESS_1})314 self.assertEqual(True, resp['return'])315 self.assertEqual(1, self.nova.servers.remove_floating_ip.call_count)316 def test_dissassociate_address_vpc(self):317 address.address_engine = (318 address.AddressEngineNeutron())319 self.set_mock_db_items(fakes.DB_ADDRESS_2)320 self.neutron.show_floatingip.return_value = (321 {'floatingip': fakes.OS_FLOATING_IP_2})322 resp = self.execute('DisassociateAddress',323 {'AssociationId': fakes.ID_EC2_ASSOCIATION_2})324 self.assertEqual(True, resp['return'])325 self.neutron.update_floatingip.assert_called_once_with(326 fakes.ID_OS_FLOATING_IP_2,327 {'floatingip': {'port_id': None}})328 self.db_api.update_item.assert_called_once_with(329 mock.ANY,330 tools.purge_dict(fakes.DB_ADDRESS_2, ['network_interface_id',331 'private_ip_address']))332 def test_dissassociate_address_vpc_idempotent(self):333 address.address_engine = (334 address.AddressEngineNeutron())335 self.set_mock_db_items(fakes.DB_ADDRESS_1)336 self.neutron.show_floatingip.return_value = (337 {'floatingip': fakes.OS_FLOATING_IP_1})338 resp = self.execute('DisassociateAddress',339 {'AssociationId': fakes.ID_EC2_ASSOCIATION_1})340 self.assertEqual(True, resp['return'])341 self.assertEqual(0, self.neutron.update_floatingip.call_count)342 self.assertEqual(0, self.db_api.update_item.call_count)343 def test_disassociate_address_invalid_parameters(self):344 address.address_engine = (345 address.AddressEngineNeutron())346 def do_check(params, error):347 self.assert_execution_error(error, 'DisassociateAddress', params)348 do_check({},349 'MissingParameter')350 do_check({'PublicIp': '0.0.0.0',351 'AssociationId': 'eipassoc-0'},352 'InvalidParameterCombination')353 # NOTE(ft): EC2 Classic public IP does not exists354 self.set_mock_db_items()355 self.nova.floating_ips.list.return_value = []356 self.assert_execution_error('AuthFailure', 'DisassociateAddress',357 {'PublicIp': fakes.IP_ADDRESS_2})358 # NOTE(ft): vpc address vs public ip parameter359 self.set_mock_db_items(fakes.DB_ADDRESS_1)360 self.neutron.show_floatingip.return_value = (361 {'floatingip': fakes.OS_FLOATING_IP_1})362 do_check({'PublicIp': fakes.IP_ADDRESS_1},363 'InvalidParameterValue')364 # NOTE(ft): not registered address365 self.set_mock_db_items()366 do_check({'AssociationId': fakes.ID_EC2_ASSOCIATION_1},367 'InvalidAssociationID.NotFound')368 # NOTE(ft): registered broken vpc address369 self.set_mock_db_items(fakes.DB_ADDRESS_2)370 self.neutron.show_floatingip.side_effect = neutron_exception.NotFound371 do_check({'AssociationId': fakes.ID_EC2_ASSOCIATION_2},372 'InvalidAssociationID.NotFound')373 @tools.screen_unexpected_exception_logs374 def test_dissassociate_address_vpc_rollback(self):375 address.address_engine = (376 address.AddressEngineNeutron())377 self.set_mock_db_items(fakes.DB_ADDRESS_2)378 self.neutron.show_floatingip.return_value = (379 {'floatingip': fakes.OS_FLOATING_IP_2})380 self.neutron.update_floatingip.side_effect = Exception()381 self.assert_execution_error(382 self.ANY_EXECUTE_ERROR, 'DisassociateAddress',383 {'AssociationId': fakes.ID_EC2_ASSOCIATION_2})384 self.db_api.update_item.assert_any_call(385 mock.ANY, fakes.DB_ADDRESS_2)386 def test_release_address_ec2_classic(self):387 address.address_engine = (388 address.AddressEngineNeutron())389 self.set_mock_db_items()390 self.nova.floating_ips.delete.return_value = True391 self.nova.floating_ips.list.return_value = (392 [fakes.NovaFloatingIp(fakes.NOVA_FLOATING_IP_1),393 fakes.NovaFloatingIp(fakes.NOVA_FLOATING_IP_2)])394 resp = self.execute('ReleaseAddress',395 {'PublicIp': fakes.IP_ADDRESS_1})396 self.assertEqual(True, resp['return'])397 self.nova.floating_ips.delete.assert_called_once_with(398 fakes.NOVA_FLOATING_IP_1['id'])399 def test_release_address_vpc(self):400 address.address_engine = (401 address.AddressEngineNeutron())402 self.set_mock_db_items(fakes.DB_ADDRESS_1)403 self.neutron.show_floatingip.return_value = (404 {'floatingip': fakes.OS_FLOATING_IP_1})405 resp = self.execute('ReleaseAddress',406 {'AllocationId': fakes.ID_EC2_ADDRESS_1})407 self.assertEqual(True, resp['return'])408 self.neutron.delete_floatingip.assert_called_once_with(409 fakes.ID_OS_FLOATING_IP_1)410 self.db_api.delete_item.assert_called_once_with(411 mock.ANY, fakes.ID_EC2_ADDRESS_1)412 def test_release_address_invalid_parameters(self):413 address.address_engine = (414 address.AddressEngineNeutron())415 def do_check(params, error):416 self.assert_execution_error(error, 'ReleaseAddress', params)417 do_check({},418 'MissingParameter')419 do_check({'PublicIp': '0.0.0.0',420 'AllocationId': 'eipalloc-0'},421 'InvalidParameterCombination')422 # NOTE(ft): EC2 Classic public IP is not found423 self.nova.floating_ips.list.return_value = []424 do_check({'PublicIp': fakes.IP_ADDRESS_1},425 'AuthFailure')426 # NOTE(ft): vpc address vs public ip parameter427 self.set_mock_db_items(fakes.DB_ADDRESS_1)428 self.neutron.show_floatingip.return_value = (429 {'floatingip': fakes.OS_FLOATING_IP_1})430 do_check({'PublicIp': fakes.IP_ADDRESS_1},431 'InvalidParameterValue')432 # NOTE(ft): not registered address433 self.set_mock_db_items()434 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1},435 'InvalidAllocationID.NotFound')436 # NOTE(ft): registered broken vpc address437 self.set_mock_db_items(fakes.DB_ADDRESS_1)438 self.neutron.show_floatingip.side_effect = neutron_exception.NotFound439 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_1},440 'InvalidAllocationID.NotFound')441 self.neutron.show_floatingip.side_effect = None442 # NOTE(ft): address is in use443 self.set_mock_db_items(fakes.DB_ADDRESS_2)444 self.neutron.show_floatingip.return_value = (445 {'floatingip': fakes.OS_FLOATING_IP_2})446 do_check({'AllocationId': fakes.ID_EC2_ADDRESS_2},447 'InvalidIPAddress.InUse')448 @tools.screen_unexpected_exception_logs449 def test_release_address_vpc_rollback(self):450 address.address_engine = (451 address.AddressEngineNeutron())452 self.set_mock_db_items(fakes.DB_ADDRESS_1)453 self.neutron.show_floatingip.return_value = (454 {'floatingip': fakes.OS_FLOATING_IP_1})455 self.neutron.delete_floatingip.side_effect = Exception()456 self.assert_execution_error(self.ANY_EXECUTE_ERROR, 'ReleaseAddress',457 {'AllocationId': fakes.ID_EC2_ADDRESS_1})458 self.db_api.restore_item.assert_called_once_with(459 mock.ANY, 'eipalloc', fakes.DB_ADDRESS_1)460 def test_describe_addresses_vpc(self):461 address.address_engine = (462 address.AddressEngineNeutron())463 self.neutron.list_floatingips.return_value = (464 {'floatingips': [fakes.OS_FLOATING_IP_1,465 fakes.OS_FLOATING_IP_2]})466 self.neutron.list_ports.return_value = (467 {'ports': [fakes.OS_PORT_1,468 fakes.OS_PORT_2]})469 self.set_mock_db_items(470 fakes.DB_ADDRESS_1, fakes.DB_ADDRESS_2, fakes.DB_INSTANCE_1,471 fakes.DB_NETWORK_INTERFACE_1, fakes.DB_NETWORK_INTERFACE_2)472 resp = self.execute('DescribeAddresses', {})473 self.assertThat(resp['addressesSet'],474 matchers.ListMatches([fakes.EC2_ADDRESS_1,475 fakes.EC2_ADDRESS_2]))476 self.db_api.get_items_by_ids = tools.CopyingMock(477 return_value=[fakes.DB_ADDRESS_1])478 resp = self.execute('DescribeAddresses',479 {'AllocationId.1': fakes.ID_EC2_ADDRESS_1})480 self.assertThat(resp['addressesSet'],481 matchers.ListMatches([fakes.EC2_ADDRESS_1]))482 self.db_api.get_items_by_ids.assert_called_once_with(483 mock.ANY, set([fakes.ID_EC2_ADDRESS_1]))484 self.check_filtering(485 'DescribeAddresses', 'addressesSet',486 [('allocation-id', fakes.ID_EC2_ADDRESS_1),487 ('association-id', fakes.ID_EC2_ASSOCIATION_2),488 ('domain', 'vpc'),489 ('instance-id', fakes.ID_EC2_INSTANCE_1),490 ('network-interface-id', fakes.ID_EC2_NETWORK_INTERFACE_2),491 ('network-interface-owner-id', fakes.ID_OS_PROJECT),492 ('private-ip-address', fakes.IP_NETWORK_INTERFACE_2),493 ('public-ip', fakes.IP_ADDRESS_2)])494 def test_describe_addresses_ec2_classic(self):495 address.address_engine = (496 address.AddressEngineNova())497 self.set_mock_db_items(fakes.DB_INSTANCE_1)498 self.nova.floating_ips.list.return_value = [499 fakes.NovaFloatingIp(fakes.NOVA_FLOATING_IP_1),500 fakes.NovaFloatingIp(fakes.NOVA_FLOATING_IP_2)]501 resp = self.execute('DescribeAddresses', {})502 self.assertThat(resp['addressesSet'],503 matchers.ListMatches([fakes.EC2_ADDRESS_CLASSIC_1,504 fakes.EC2_ADDRESS_CLASSIC_2]))505 resp = self.execute('DescribeAddresses', {'PublicIp.1':506 fakes.IP_ADDRESS_2})507 self.assertThat(resp['addressesSet'],...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!