<s> import uuid <EOL> import mock <EOL> import six <EOL> import webob <EOL> import webob . exc <EOL> from ooi . api import compute <EOL> from ooi . api import helpers <EOL> from ooi import exception <EOL> from ooi . occi . core import collection <EOL> from ooi . occi . infrastructure import compute as occi_compute <EOL> from ooi . occi . infrastructure import storage as occi_storage <EOL> from ooi . openstack import contextualization <EOL> from ooi . openstack import templates <EOL> from ooi . tests import base <EOL> from ooi . tests import fakes <EOL> class TestComputeController ( base . TestController ) : <EOL> def setUp ( self ) : <EOL> super ( TestComputeController , self ) . setUp ( ) <EOL> self . controller = compute . Controller ( mock . MagicMock ( ) , None ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT:index>" ) <EOL> def test_index ( self , m_index ) : <EOL> test_servers = [ <EOL> [ ] , <EOL> fakes . servers [ fakes . tenants [ "<STR_LIT:foo>" ] [ "<STR_LIT:id>" ] ] <EOL> ] <EOL> for servers in test_servers : <EOL> m_index . return_value = servers <EOL> result = self . controller . index ( None ) <EOL> expected = self . controller . _get_compute_resources ( servers ) <EOL> self . assertEqual ( expected , result . resources ) <EOL> m_index . assert_called_with ( None ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> def test_get_server_floating_ips_no_ips ( self , mock_get_server ) : <EOL> mock_get_server . return_value = { } <EOL> ret = self . controller . _get_server_floating_ips ( None , "<STR_LIT:foo>" ) <EOL> mock_get_server . assert_called_with ( None , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( [ ] , ret ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> def test_get_server_floating_ips_with_ips ( self , mock_get_server ) : <EOL> mock_get_server . return_value = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> ] <EOL> } <EOL> } <EOL> ret = self . controller . _get_server_floating_ips ( None , "<STR_LIT:foo>" ) <EOL> mock_get_server . assert_called_with ( None , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( [ "<STR_LIT>" , "<STR_LIT>" ] , ret ) <EOL> @ mock . patch . object ( compute . Controller , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> def test_release_floating_ips ( self , mock_release , mock_remove , <EOL> mock_get_floating , <EOL> mock_server_floating ) : <EOL> mock_server_floating . return_value = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> mock_get_floating . return_value = [ <EOL> { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:id>" : "<STR_LIT:bar>" } , <EOL> { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:id>" : "<STR_LIT>" } , <EOL> ] <EOL> self . controller . _release_floating_ips ( None , "<STR_LIT:foo>" ) <EOL> mock_server_floating . assert_called_with ( None , "<STR_LIT:foo>" ) <EOL> mock_get_floating . assert_called_with ( None ) <EOL> mock_remove . assert_has_calls ( [ mock . call ( None , "<STR_LIT:foo>" , "<STR_LIT>" ) , <EOL> mock . call ( None , "<STR_LIT:foo>" , "<STR_LIT>" ) ] ) <EOL> mock_release . assert_has_calls ( [ mock . call ( None , "<STR_LIT:bar>" ) , <EOL> mock . call ( None , "<STR_LIT>" ) ] ) <EOL> @ mock . patch . object ( compute . Controller , "<STR_LIT>" ) <EOL> def test_delete ( self , mock_delete ) : <EOL> mock_delete . return_value = [ ] <EOL> ret = self . controller . delete ( None , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( [ ] , ret ) <EOL> mock_delete . assert_called_with ( None , [ "<STR_LIT:foo>" ] ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( compute . Controller , "<STR_LIT>" ) <EOL> def test_delete_ids ( self , mock_release , mock_delete ) : <EOL> server_ids = [ uuid . uuid4 ( ) . hex , uuid . uuid4 ( ) . hex ] <EOL> mock_delete . return_value = None <EOL> ret = self . controller . _delete ( None , server_ids ) <EOL> self . assertEqual ( [ ] , ret ) <EOL> mock_delete . assert_has_calls ( [ mock . call ( None , s ) for s in server_ids ] ) <EOL> mock_release . assert_has_calls ( [ mock . call ( None , s ) for s in server_ids ] ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT:index>" ) <EOL> @ mock . patch . object ( compute . Controller , "<STR_LIT>" ) <EOL> def test_delete_all ( self , mock_delete , mock_index ) : <EOL> servers = [ { "<STR_LIT:id>" : uuid . uuid4 ( ) . hex } , { "<STR_LIT:id>" : uuid . uuid4 ( ) . hex } ] <EOL> mock_index . return_value = servers <EOL> mock_delete . return_value = [ ] <EOL> ret = self . controller . delete_all ( None ) <EOL> self . assertEqual ( [ ] , ret ) <EOL> mock_delete . assert_called_with ( None , [ s [ "<STR_LIT:id>" ] for s in servers ] ) <EOL> def test_run_action_none ( self ) : <EOL> tenant = fakes . tenants [ "<STR_LIT:foo>" ] <EOL> req = self . _build_req ( tenant [ "<STR_LIT:id>" ] ) <EOL> self . assertRaises ( exception . InvalidAction , <EOL> self . controller . run_action , <EOL> req , <EOL> None , <EOL> None ) <EOL> def test_run_action_invalid ( self ) : <EOL> tenant = fakes . tenants [ "<STR_LIT:foo>" ] <EOL> req = self . _build_req ( tenant [ "<STR_LIT:id>" ] , path = "<STR_LIT>" ) <EOL> server_uuid = uuid . uuid4 ( ) . hex <EOL> self . assertRaises ( exception . InvalidAction , <EOL> self . controller . run_action , <EOL> req , <EOL> server_uuid , <EOL> None ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_run_action_start ( self , m_validator , m_get_server , m_run_action ) : <EOL> tenant = fakes . tenants [ "<STR_LIT:foo>" ] <EOL> action = "<STR_LIT:start>" <EOL> state_action_map = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:start>" , <EOL> } <EOL> req = self . _build_req ( tenant [ "<STR_LIT:id>" ] , path = "<STR_LIT>" ) <EOL> for state , action in six . iteritems ( state_action_map ) : <EOL> req . get_parser = mock . MagicMock ( ) <EOL> server_uuid = uuid . uuid4 ( ) . hex <EOL> server = { "<STR_LIT:status>" : state } <EOL> m_get_server . return_value = server <EOL> m_run_action . return_value = None <EOL> ret = self . controller . run_action ( req , server_uuid , None ) <EOL> self . assertEqual ( [ ] , ret ) <EOL> m_run_action . assert_called_with ( mock . ANY , action , server_uuid ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> def test_show ( self , m_server , m_flavor , m_image , m_vol ) : <EOL> for tenant in fakes . tenants . values ( ) : <EOL> servers = fakes . servers [ tenant [ "<STR_LIT:id>" ] ] <EOL> for server in servers : <EOL> flavor = fakes . flavors [ server [ "<STR_LIT>" ] [ "<STR_LIT:id>" ] ] <EOL> image = fakes . images [ server [ "<STR_LIT:image>" ] [ "<STR_LIT:id>" ] ] <EOL> volumes = fakes . volumes . get ( tenant [ "<STR_LIT:id>" ] , [ ] ) <EOL> if volumes : <EOL> volumes = volumes [ <NUM_LIT:0> ] [ "<STR_LIT>" ] <EOL> m_server . return_value = server <EOL> m_flavor . return_value = flavor <EOL> m_image . return_value = image <EOL> m_vol . return_value = volumes <EOL> ret = self . controller . show ( None , server [ "<STR_LIT:id>" ] ) <EOL> self . assertIsInstance ( ret [ <NUM_LIT:0> ] , occi_compute . ComputeResource ) <EOL> m_server . assert_called_with ( None , server [ "<STR_LIT:id>" ] ) <EOL> m_flavor . assert_called_with ( None , flavor [ "<STR_LIT:id>" ] ) <EOL> m_image . assert_called_with ( None , image [ "<STR_LIT:id>" ] ) <EOL> m_vol . assert_called_with ( None , server [ "<STR_LIT:id>" ] ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> def test_show_no_image ( self , m_server , m_flavor , m_image , m_vol ) : <EOL> for tenant in fakes . tenants . values ( ) : <EOL> servers = fakes . servers [ tenant [ "<STR_LIT:id>" ] ] <EOL> for server in servers : <EOL> flavor = fakes . flavors [ server [ "<STR_LIT>" ] [ "<STR_LIT:id>" ] ] <EOL> image = fakes . images [ server [ "<STR_LIT:image>" ] [ "<STR_LIT:id>" ] ] <EOL> volumes = fakes . volumes . get ( tenant [ "<STR_LIT:id>" ] , [ ] ) <EOL> if volumes : <EOL> volumes = volumes [ <NUM_LIT:0> ] [ "<STR_LIT>" ] <EOL> m_server . return_value = server <EOL> m_flavor . return_value = flavor <EOL> m_image . side_effect = webob . exc . HTTPNotFound ( ) <EOL> m_vol . return_value = volumes <EOL> ret = self . controller . show ( None , server [ "<STR_LIT:id>" ] ) <EOL> self . assertIsInstance ( ret [ <NUM_LIT:0> ] , occi_compute . ComputeResource ) <EOL> m_server . assert_called_with ( None , server [ "<STR_LIT:id>" ] ) <EOL> m_flavor . assert_called_with ( None , flavor [ "<STR_LIT:id>" ] ) <EOL> m_image . assert_called_with ( None , image [ "<STR_LIT:id>" ] ) <EOL> m_vol . assert_called_with ( None , server [ "<STR_LIT:id>" ] ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_create_server ( self , m_validator , m_create ) : <EOL> tenant = fakes . tenants [ "<STR_LIT:foo>" ] <EOL> req = self . _build_req ( tenant [ "<STR_LIT:id>" ] ) <EOL> obj = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> "<STR_LIT>" : { <EOL> templates . OpenStackOSTemplate . scheme : [ "<STR_LIT:foo>" ] , <EOL> templates . OpenStackResourceTemplate . scheme : [ "<STR_LIT:bar>" ] , <EOL> } , <EOL> } <EOL> req . get_parser = mock . MagicMock ( ) <EOL> req . get_parser . return_value . return_value . parse . return_value = obj <EOL> m_validator . validate . return_value = True <EOL> server = { "<STR_LIT:id>" : uuid . uuid4 ( ) . hex } <EOL> m_create . return_value = server <EOL> ret = self . controller . create ( req , None ) <EOL> self . assertIsInstance ( ret , collection . Collection ) <EOL> m_create . assert_called_with ( mock . ANY , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT:bar>" , <EOL> user_data = None , <EOL> key_name = None , <EOL> block_device_mapping_v2 = [ ] ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_create_server_with_context ( self , m_validator , m_create ) : <EOL> tenant = fakes . tenants [ "<STR_LIT:foo>" ] <EOL> req = self . _build_req ( tenant [ "<STR_LIT:id>" ] ) <EOL> obj = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> "<STR_LIT>" : { <EOL> templates . OpenStackOSTemplate . scheme : [ "<STR_LIT:foo>" ] , <EOL> templates . OpenStackResourceTemplate . scheme : [ "<STR_LIT:bar>" ] , <EOL> contextualization . user_data . scheme : None , <EOL> contextualization . public_key . scheme : None , <EOL> } , <EOL> } <EOL> req . get_parser = mock . MagicMock ( ) <EOL> req . get_parser . return_value . return_value . parse . return_value = obj <EOL> m_validator . validate . return_value = True <EOL> server = { "<STR_LIT:id>" : uuid . uuid4 ( ) . hex } <EOL> m_create . return_value = server <EOL> ret = self . controller . create ( req , None ) <EOL> self . assertIsInstance ( ret , collection . Collection ) <EOL> m_create . assert_called_with ( mock . ANY , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT:bar>" , <EOL> user_data = "<STR_LIT>" , <EOL> key_name = None , <EOL> block_device_mapping_v2 = [ ] ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_create_server_with_sshkeys ( self , m_validator , m_server , <EOL> m_keypair ) : <EOL> tenant = fakes . tenants [ "<STR_LIT:foo>" ] <EOL> req = self . _build_req ( tenant [ "<STR_LIT:id>" ] ) <EOL> obj = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> templates . OpenStackOSTemplate . scheme : [ "<STR_LIT:foo>" ] , <EOL> templates . OpenStackResourceTemplate . scheme : [ "<STR_LIT:bar>" ] , <EOL> contextualization . public_key . scheme : None , <EOL> } , <EOL> } <EOL> req . get_parser = mock . MagicMock ( ) <EOL> req . get_parser . return_value . return_value . parse . return_value = obj <EOL> m_validator . validate . return_value = True <EOL> server = { "<STR_LIT:id>" : uuid . uuid4 ( ) . hex } <EOL> m_server . return_value = server <EOL> m_keypair . return_value = None <EOL> ret = self . controller . create ( req , None ) <EOL> self . assertIsInstance ( ret , collection . Collection ) <EOL> m_keypair . assert_called_with ( mock . ANY , "<STR_LIT>" , <EOL> public_key = "<STR_LIT>" ) <EOL> m_server . assert_called_with ( mock . ANY , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT:bar>" , <EOL> user_data = None , <EOL> key_name = "<STR_LIT>" , <EOL> block_device_mapping_v2 = [ ] ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_create_server_with_no_sshkey_name ( self , m_validator , m_server , <EOL> m_keypair , m_keypair_delete ) : <EOL> tenant = fakes . tenants [ "<STR_LIT:foo>" ] <EOL> req = self . _build_req ( tenant [ "<STR_LIT:id>" ] ) <EOL> obj = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> "<STR_LIT>" : { <EOL> templates . OpenStackOSTemplate . scheme : [ "<STR_LIT:foo>" ] , <EOL> templates . OpenStackResourceTemplate . scheme : [ "<STR_LIT:bar>" ] , <EOL> contextualization . public_key . scheme : None , <EOL> } , <EOL> } <EOL> req . get_parser = mock . MagicMock ( ) <EOL> req . get_parser . return_value . return_value . parse . return_value = obj <EOL> m_validator . validate . return_value = True <EOL> server = { "<STR_LIT:id>" : uuid . uuid4 ( ) . hex } <EOL> m_server . return_value = server <EOL> m_keypair . return_value = None <EOL> ret = self . controller . create ( req , None ) <EOL> self . assertIsInstance ( ret , collection . Collection ) <EOL> m_keypair . assert_called_with ( mock . ANY , mock . ANY , <EOL> public_key = "<STR_LIT>" ) <EOL> m_server . assert_called_with ( mock . ANY , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT:bar>" , <EOL> user_data = None , <EOL> key_name = mock . ANY , <EOL> block_device_mapping_v2 = [ ] ) <EOL> m_keypair_delete . assert_called_with ( mock . ANY , mock . ANY ) <EOL> def test_build_block_mapping_no_links ( self ) : <EOL> ret = self . controller . _build_block_mapping ( None , { } ) <EOL> self . assertEqual ( [ ] , ret ) <EOL> def test_build_block_mapping_invalid_rel ( self ) : <EOL> obj = { '<STR_LIT>' : { '<STR_LIT:foo>' : { '<STR_LIT>' : '<STR_LIT:bar>' } } } <EOL> ret = self . controller . _build_block_mapping ( None , obj ) <EOL> self . assertEqual ( [ ] , ret ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_build_block_mapping ( self , m_get_id ) : <EOL> vol_id = uuid . uuid4 ( ) . hex <EOL> image_id = uuid . uuid4 ( ) . hex <EOL> obj = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : ( '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : vol_id , <EOL> } <EOL> } , <EOL> "<STR_LIT>" : { <EOL> templates . OpenStackOSTemplate . scheme : [ image_id ] , <EOL> } <EOL> } <EOL> m_get_id . return_value = ( None , vol_id ) <EOL> ret = self . controller . _build_block_mapping ( None , obj ) <EOL> expected = [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT:image>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : image_id , <EOL> } , <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : vol_id , <EOL> "<STR_LIT>" : False , <EOL> } <EOL> ] <EOL> self . assertEqual ( expected , ret ) <EOL> m_get_id . assert_called_with ( None , vol_id , <EOL> occi_storage . StorageResource . kind ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_build_block_mapping_device_id ( self , m_get_id ) : <EOL> vol_id = uuid . uuid4 ( ) . hex <EOL> image_id = uuid . uuid4 ( ) . hex <EOL> obj = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : ( '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : vol_id , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> } , <EOL> "<STR_LIT>" : { <EOL> templates . OpenStackOSTemplate . scheme : [ image_id ] , <EOL> } <EOL> } <EOL> m_get_id . return_value = ( None , vol_id ) <EOL> ret = self . controller . _build_block_mapping ( None , obj ) <EOL> expected = [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT:image>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : image_id , <EOL> } , <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : vol_id , <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> ] <EOL> self . assertEqual ( expected , ret ) <EOL> m_get_id . assert_called_with ( None , vol_id , <EOL> occi_storage . StorageResource . kind ) <EOL> @ mock . patch . object ( helpers . OpenStackHelper , "<STR_LIT>" ) <EOL> @ mock . patch . object ( compute . Controller , "<STR_LIT>" ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_create_server_with_storage_link ( self , m_validator , m_block , <EOL> m_server ) : <EOL> tenant = fakes . tenants [ "<STR_LIT:foo>" ] <EOL> req = self . _build_req ( tenant [ "<STR_LIT:id>" ] ) <EOL> obj = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> "<STR_LIT>" : { <EOL> templates . OpenStackOSTemplate . scheme : [ "<STR_LIT:foo>" ] , <EOL> templates . OpenStackResourceTemplate . scheme : [ "<STR_LIT:bar>" ] , <EOL> } , <EOL> } <EOL> req . get_parser = mock . MagicMock ( ) <EOL> req . get_parser . return_value . return_value . parse . return_value = obj <EOL> m_validator . validate . return_value = True <EOL> server = { "<STR_LIT:id>" : uuid . uuid4 ( ) . hex } <EOL> m_server . return_value = server <EOL> m_block . return_value = "<STR_LIT>" <EOL> ret = self . controller . create ( req , None ) <EOL> self . assertIsInstance ( ret , collection . Collection ) <EOL> m_server . assert_called_with ( mock . ANY , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT:bar>" , <EOL> user_data = None , <EOL> key_name = mock . ANY , <EOL> block_device_mapping_v2 = "<STR_LIT>" ) <EOL> m_block . assert_called_with ( req , obj ) </s>
