#NEWLINE# def test_assign_unassign_private_addresses_by_addresses( self ) : #NEWLINE# #INDENT# data = self . client . describe_subnets ( SubnetIds = [ self . subnet_id ] ) #NEWLINE# count = data [ 'Subnets' ] [ 0 ] [ 'AvailableIpAddressCount' ] #NEWLINE# data = self . client . create_network_interface ( SubnetId = self . subnet_id ) #NEWLINE# ni_id = data [ 'NetworkInterface' ] [ 'NetworkInterfaceId' ] #NEWLINE# res_clean = self . addResourceCleanUp ( self . client . delete_network_interface , NetworkInterfaceId = ni_id ) #NEWLINE# self . get_network_interface_waiter ( ) . wait_available ( ni_id ) #NEWLINE# addresses = [ '10.7.0.10' , '10.7.0.11' ] #NEWLINE# data = self . client . assign_private_ip_addresses ( NetworkInterfaceId = ni_id , PrivateIpAddresses = addresses ) #NEWLINE# self . _wait_assignment ( ni_id , data ) #NEWLINE# data = self . client . describe_subnets ( SubnetIds = [ self . subnet_id ] ) #NEWLINE# count_after = data [ 'Subnets' ] [ 0 ] [ 'AvailableIpAddressCount' ] #NEWLINE# self . assertIn ( count_after , [ ( count - 3 ) , ( count - 4 ) ] ) #NEWLINE# data = self . client . describe_network_interfaces ( NetworkInterfaceIds = [ ni_id ] ) #NEWLINE# assigned_addresses = [ ] #NEWLINE# for addr in data [ 'NetworkInterfaces' ] [ 0 ] [ 'PrivateIpAddresses' ] : #NEWLINE# #INDENT# if ( not addr [ 'Primary' ] ) : #NEWLINE# #INDENT# self . assertIn ( addr [ 'PrivateIpAddress' ] , addresses ) #NEWLINE# assigned_addresses . append ( addr [ 'PrivateIpAddress' ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( 2 , len ( assigned_addresses ) ) #NEWLINE# data = self . client . unassign_private_ip_addresses ( NetworkInterfaceId = ni_id , PrivateIpAddresses = addresses ) #NEWLINE# self . _wait_assignment ( ni_id , data ) #NEWLINE# data = self . client . describe_subnets ( SubnetIds = [ self . subnet_id ] ) #NEWLINE# count_after = data [ 'Subnets' ] [ 0 ] [ 'AvailableIpAddressCount' ] #NEWLINE# self . assertIn ( count_after , [ ( count - 1 ) , ( count - 2 ) ] ) #NEWLINE# self . client . delete_network_interface ( NetworkInterfaceId = ni_id ) #NEWLINE# self . cancelResourceCleanUp ( res_clean ) #NEWLINE# self . get_network_interface_waiter ( ) . wait_delete ( ni_id )