#NEWLINE# def test_add_associated_floating_ip_to_instance( self ) : #NEWLINE# #INDENT# def fake_fixed_ip_get_by_address( ctx , address , session = None ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'address' : address , #NEWLINE# 'network' : { #NEWLINE# #INDENT# 'multi_host' : None , #NEWLINE# 'host' : 'fake' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# self . disassociated = False #NEWLINE# def fake_network_api_disassociate( local_self , ctx , floating_address ) : #NEWLINE# #INDENT# self . disassociated = True #NEWLINE# #UNINDENT# db . floating_ip_update ( self . context , self . address , { #NEWLINE# #INDENT# 'project_id' : '123' , #NEWLINE# 'fixed_ip_id' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . stubs . Set ( network . api . API , 'disassociate_floating_ip' , fake_network_api_disassociate ) #NEWLINE# self . stubs . Set ( db . api , 'fixed_ip_get_by_address' , fake_fixed_ip_get_by_address ) #NEWLINE# body = dict ( addFloatingIp = dict ( address = body . address ) ) #NEWLINE# req = webob . Request . blank ( '/v1.1/123/servers/test_inst/action' ) #NEWLINE# req . method = 'POST' #NEWLINE# req . body = json . dumps ( body ) #NEWLINE# req . headers [ 'content-type' ] = 'application/json' #NEWLINE# resp = req . get_response ( fakes . wsgi_app ( ) ) #NEWLINE# self . assertEqual ( resp . status_int , 202 ) #NEWLINE# self . assertTrue ( self . disassociated )