<s> """<STR_LIT>""" <EOL> from mock import patch <EOL> import os_client_config <EOL> from shade import meta <EOL> from shade import OpenStackCloud <EOL> from shade . tests . fakes import FakeServer <EOL> from shade . tests . unit import base <EOL> class TestFloatingIP ( base . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestFloatingIP , self ) . setUp ( ) <EOL> config = os_client_config . OpenStackConfig ( ) <EOL> self . client = OpenStackCloud ( <EOL> cloud_config = config . get_one_cloud ( validate = False ) ) <EOL> @ patch . object ( OpenStackCloud , '<STR_LIT>' ) <EOL> @ patch . object ( OpenStackCloud , '<STR_LIT>' ) <EOL> @ patch . object ( OpenStackCloud , '<STR_LIT>' ) <EOL> def test_add_auto_ip ( <EOL> self , mock_available_floating_ip , mock_attach_ip_to_server , <EOL> mock_get_floating_ip ) : <EOL> server = FakeServer ( <EOL> id = '<STR_LIT>' , name = '<STR_LIT>' , status = "<STR_LIT>" , addresses = { } <EOL> ) <EOL> server_dict = meta . obj_to_dict ( server ) <EOL> floating_ip_dict = { <EOL> "<STR_LIT:id>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT:status>" : "<STR_LIT>" <EOL> } <EOL> mock_available_floating_ip . return_value = floating_ip_dict <EOL> self . client . add_auto_ip ( server = server_dict ) <EOL> mock_attach_ip_to_server . assert_called_with ( <EOL> timeout = <NUM_LIT> , wait = False , server = server_dict , <EOL> floating_ip = floating_ip_dict , skip_attach = False ) <EOL> @ patch . object ( OpenStackCloud , '<STR_LIT>' ) <EOL> @ patch . object ( OpenStackCloud , '<STR_LIT>' ) <EOL> def test_add_ips_to_server_pool ( <EOL> self , mock_add_ip_from_pool , mock_nova_client ) : <EOL> server = FakeServer ( <EOL> id = '<STR_LIT>' , name = '<STR_LIT>' , status = "<STR_LIT>" , addresses = { } <EOL> ) <EOL> server_dict = meta . obj_to_dict ( server ) <EOL> pool = '<STR_LIT>' <EOL> mock_nova_client . servers . get . return_value = server <EOL> self . client . add_ips_to_server ( server_dict , ip_pool = pool ) <EOL> mock_add_ip_from_pool . assert_called_with ( <EOL> server_dict , pool , reuse = True , wait = False , timeout = <NUM_LIT> , <EOL> fixed_address = None , nat_destination = None ) <EOL> @ patch . object ( OpenStackCloud , '<STR_LIT>' ) <EOL> @ patch . object ( OpenStackCloud , '<STR_LIT>' ) <EOL> def test_add_ips_to_server_ip_list ( <EOL> self , mock_add_ip_list , mock_nova_client ) : <EOL> server = FakeServer ( <EOL> id = '<STR_LIT>' , name = '<STR_LIT>' , status = "<STR_LIT>" , addresses = { } <EOL> ) <EOL> server_dict = meta . obj_to_dict ( server ) <EOL> ips = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> mock_nova_client . servers . get . return_value = server <EOL> self . client . add_ips_to_server ( server_dict , ips = ips ) <EOL> mock_add_ip_list . assert_called_with ( <EOL> server_dict , ips , wait = False , timeout = <NUM_LIT> , fixed_address = None ) <EOL> @ patch . object ( OpenStackCloud , '<STR_LIT>' ) <EOL> @ patch . object ( OpenStackCloud , '<STR_LIT>' ) <EOL> def test_add_ips_to_server_auto_ip ( <EOL> self , mock_add_auto_ip , mock_nova_client ) : <EOL> server = FakeServer ( <EOL> id = '<STR_LIT>' , name = '<STR_LIT>' , status = "<STR_LIT>" , addresses = { } <EOL> ) <EOL> server_dict = meta . obj_to_dict ( server ) <EOL> mock_nova_client . servers . get . return_value = server <EOL> self . client . add_ips_to_server ( server_dict ) <EOL> mock_add_auto_ip . assert_called_with ( <EOL> server_dict , wait = False , timeout = <NUM_LIT> , reuse = True ) </s>
