<s> import mock <EOL> from openstack_dashboard . api . rest import network <EOL> from openstack_dashboard . test import helpers as test <EOL> class RestNetworkApiSecurityGroupTests ( test . TestCase ) : <EOL> @ mock . patch . object ( network . api , '<STR_LIT>' ) <EOL> def test_security_group_detailed ( self , client ) : <EOL> request = self . mock_rest_request ( ) <EOL> client . security_group_list . return_value = [ <EOL> mock . Mock ( ** { '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT:default>' } } ) , <EOL> ] <EOL> response = network . SecurityGroups ( ) . get ( request ) <EOL> self . assertStatusCode ( response , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . json , <EOL> { "<STR_LIT>" : [ { "<STR_LIT:name>" : "<STR_LIT:default>" } ] } ) <EOL> client . security_group_list . assert_called_once_with ( request ) <EOL> class RestNetworkApiFloatingIpTests ( test . TestCase ) : <EOL> @ mock . patch . object ( network . api , '<STR_LIT>' ) <EOL> def test_floating_ip_list ( self , client ) : <EOL> request = self . mock_rest_request ( ) <EOL> client . tenant_floating_ip_list . return_value = ( [ <EOL> mock . Mock ( ** { '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } ) , <EOL> mock . Mock ( ** { '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } ) <EOL> ] ) <EOL> response = network . FloatingIPs ( ) . get ( request ) <EOL> self . assertStatusCode ( response , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . json , <EOL> { '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' } , { '<STR_LIT>' : '<STR_LIT>' } ] } ) <EOL> client . tenant_floating_ip_list . assert_called_once_with ( request ) <EOL> @ mock . patch . object ( network . api , '<STR_LIT>' ) <EOL> def test_floating_ip_pool_list ( self , client ) : <EOL> request = self . mock_rest_request ( ) <EOL> client . floating_ip_pools_list . return_value = ( [ <EOL> mock . Mock ( ** { '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT:1>' } } ) , <EOL> mock . Mock ( ** { '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT:2>' } } ) <EOL> ] ) <EOL> response = network . FloatingIPPools ( ) . get ( request ) <EOL> self . assertStatusCode ( response , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . json , <EOL> { '<STR_LIT>' : [ { '<STR_LIT:name>' : '<STR_LIT:1>' } , { '<STR_LIT:name>' : '<STR_LIT:2>' } ] } ) <EOL> client . floating_ip_pools_list . assert_called_once_with ( request ) <EOL> @ mock . patch . object ( network . api , '<STR_LIT>' ) <EOL> def test_allocate_floating_ip ( self , client ) : <EOL> request = self . mock_rest_request ( <EOL> body = '<STR_LIT>' <EOL> ) <EOL> client . tenant_floating_ip_allocate . return_value = ( <EOL> mock . Mock ( ** { '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } ) <EOL> ) <EOL> response = network . FloatingIP ( ) . post ( request ) <EOL> self . assertStatusCode ( response , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . json , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> client . tenant_floating_ip_allocate . assert_called_once_with ( request , <EOL> '<STR_LIT>' ) <EOL> @ mock . patch . object ( network . api , '<STR_LIT>' ) <EOL> def test_associate_floating_ip ( self , client ) : <EOL> request = self . mock_rest_request ( <EOL> body = '<STR_LIT>' <EOL> ) <EOL> response = network . FloatingIP ( ) . patch ( request ) <EOL> self . assertStatusCode ( response , <NUM_LIT> ) <EOL> client . floating_ip_associate . assert_called_once_with ( request , <EOL> '<STR_LIT:address>' , <EOL> '<STR_LIT:port>' ) <EOL> @ mock . patch . object ( network . api , '<STR_LIT>' ) <EOL> def test_disassociate_floating_ip ( self , client ) : <EOL> request = self . mock_rest_request ( <EOL> body = '<STR_LIT>' <EOL> ) <EOL> response = network . FloatingIP ( ) . patch ( request ) <EOL> self . assertStatusCode ( response , <NUM_LIT> ) <EOL> client . floating_ip_disassociate . assert_called_once_with ( request , <EOL> '<STR_LIT:address>' ) </s>
