<s> import copy <EOL> import mock <EOL> from mock import call <EOL> from openstackclient . common import utils <EOL> from openstackclient . tests import fakes <EOL> from openstackclient . tests . identity . v3 import fakes as identity_fakes <EOL> from openstackclient . tests . volume . v2 import fakes as volume_fakes <EOL> from openstackclient . volume . v2 import volume <EOL> class TestVolume ( volume_fakes . TestVolume ) : <EOL> def setUp ( self ) : <EOL> super ( TestVolume , self ) . setUp ( ) <EOL> self . volumes_mock = self . app . client_manager . volume . volumes <EOL> self . volumes_mock . reset_mock ( ) <EOL> self . projects_mock = self . app . client_manager . identity . projects <EOL> self . projects_mock . reset_mock ( ) <EOL> self . users_mock = self . app . client_manager . identity . users <EOL> self . users_mock . reset_mock ( ) <EOL> self . images_mock = self . app . client_manager . image . images <EOL> self . images_mock . reset_mock ( ) <EOL> self . snapshots_mock = self . app . client_manager . volume . volume_snapshots <EOL> self . snapshots_mock . reset_mock ( ) <EOL> def setup_volumes_mock ( self , count ) : <EOL> volumes = volume_fakes . FakeVolume . create_volumes ( count = count ) <EOL> self . volumes_mock . get = volume_fakes . FakeVolume . get_volumes ( <EOL> volumes , <EOL> <NUM_LIT:0> ) <EOL> return volumes <EOL> class TestVolumeCreate ( TestVolume ) : <EOL> columns = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:description>' , <EOL> '<STR_LIT:id>' , <EOL> '<STR_LIT:name>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:size>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:status>' , <EOL> '<STR_LIT:type>' , <EOL> ) <EOL> def setUp ( self ) : <EOL> super ( TestVolumeCreate , self ) . setUp ( ) <EOL> self . new_volume = volume_fakes . FakeVolume . create_one_volume ( ) <EOL> self . volumes_mock . create . return_value = self . new_volume <EOL> self . datalist = ( <EOL> self . new_volume . attachments , <EOL> self . new_volume . availability_zone , <EOL> self . new_volume . description , <EOL> self . new_volume . id , <EOL> self . new_volume . name , <EOL> utils . format_dict ( self . new_volume . metadata ) , <EOL> self . new_volume . size , <EOL> self . new_volume . snapshot_id , <EOL> self . new_volume . status , <EOL> self . new_volume . volume_type , <EOL> ) <EOL> self . cmd = volume . CreateVolume ( self . app , None ) <EOL> def test_volume_create_min_options ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , str ( self . new_volume . size ) , <EOL> self . new_volume . name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:size>' , self . new_volume . size ) , <EOL> ( '<STR_LIT:name>' , self . new_volume . name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . create . assert_called_with ( <EOL> size = self . new_volume . size , <EOL> snapshot_id = None , <EOL> name = self . new_volume . name , <EOL> description = None , <EOL> volume_type = None , <EOL> user_id = None , <EOL> project_id = None , <EOL> availability_zone = None , <EOL> metadata = None , <EOL> imageRef = None , <EOL> source_volid = None <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_volume_create_options ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , str ( self . new_volume . size ) , <EOL> '<STR_LIT>' , self . new_volume . description , <EOL> '<STR_LIT>' , self . new_volume . volume_type , <EOL> '<STR_LIT>' , self . new_volume . availability_zone , <EOL> self . new_volume . name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:size>' , self . new_volume . size ) , <EOL> ( '<STR_LIT:description>' , self . new_volume . description ) , <EOL> ( '<STR_LIT:type>' , self . new_volume . volume_type ) , <EOL> ( '<STR_LIT>' , self . new_volume . availability_zone ) , <EOL> ( '<STR_LIT:name>' , self . new_volume . name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . create . assert_called_with ( <EOL> size = self . new_volume . size , <EOL> snapshot_id = None , <EOL> name = self . new_volume . name , <EOL> description = self . new_volume . description , <EOL> volume_type = self . new_volume . volume_type , <EOL> user_id = None , <EOL> project_id = None , <EOL> availability_zone = self . new_volume . availability_zone , <EOL> metadata = None , <EOL> imageRef = None , <EOL> source_volid = None <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_volume_create_user_project_id ( self ) : <EOL> self . projects_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) <EOL> self . users_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . USER ) , <EOL> loaded = True , <EOL> ) <EOL> arglist = [ <EOL> '<STR_LIT>' , str ( self . new_volume . size ) , <EOL> '<STR_LIT>' , identity_fakes . project_id , <EOL> '<STR_LIT>' , identity_fakes . user_id , <EOL> self . new_volume . name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:size>' , self . new_volume . size ) , <EOL> ( '<STR_LIT>' , identity_fakes . project_id ) , <EOL> ( '<STR_LIT:user>' , identity_fakes . user_id ) , <EOL> ( '<STR_LIT:name>' , self . new_volume . name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . create . assert_called_with ( <EOL> size = self . new_volume . size , <EOL> snapshot_id = None , <EOL> name = self . new_volume . name , <EOL> description = None , <EOL> volume_type = None , <EOL> user_id = identity_fakes . user_id , <EOL> project_id = identity_fakes . project_id , <EOL> availability_zone = None , <EOL> metadata = None , <EOL> imageRef = None , <EOL> source_volid = None <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_volume_create_user_project_name ( self ) : <EOL> self . projects_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) <EOL> self . users_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . USER ) , <EOL> loaded = True , <EOL> ) <EOL> arglist = [ <EOL> '<STR_LIT>' , str ( self . new_volume . size ) , <EOL> '<STR_LIT>' , identity_fakes . project_name , <EOL> '<STR_LIT>' , identity_fakes . user_name , <EOL> self . new_volume . name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:size>' , self . new_volume . size ) , <EOL> ( '<STR_LIT>' , identity_fakes . project_name ) , <EOL> ( '<STR_LIT:user>' , identity_fakes . user_name ) , <EOL> ( '<STR_LIT:name>' , self . new_volume . name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . create . assert_called_with ( <EOL> size = self . new_volume . size , <EOL> snapshot_id = None , <EOL> name = self . new_volume . name , <EOL> description = None , <EOL> volume_type = None , <EOL> user_id = identity_fakes . user_id , <EOL> project_id = identity_fakes . project_id , <EOL> availability_zone = None , <EOL> metadata = None , <EOL> imageRef = None , <EOL> source_volid = None <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_volume_create_properties ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , str ( self . new_volume . size ) , <EOL> self . new_volume . name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:a>' , '<STR_LIT>' : '<STR_LIT:b>' } ) , <EOL> ( '<STR_LIT:size>' , self . new_volume . size ) , <EOL> ( '<STR_LIT:name>' , self . new_volume . name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . create . assert_called_with ( <EOL> size = self . new_volume . size , <EOL> snapshot_id = None , <EOL> name = self . new_volume . name , <EOL> description = None , <EOL> volume_type = None , <EOL> user_id = None , <EOL> project_id = None , <EOL> availability_zone = None , <EOL> metadata = { '<STR_LIT>' : '<STR_LIT:a>' , '<STR_LIT>' : '<STR_LIT:b>' } , <EOL> imageRef = None , <EOL> source_volid = None <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_volume_create_image_id ( self ) : <EOL> self . images_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( volume_fakes . IMAGE ) , <EOL> loaded = True , <EOL> ) <EOL> arglist = [ <EOL> '<STR_LIT>' , volume_fakes . image_id , <EOL> '<STR_LIT>' , str ( self . new_volume . size ) , <EOL> self . new_volume . name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:image>' , volume_fakes . image_id ) , <EOL> ( '<STR_LIT:size>' , self . new_volume . size ) , <EOL> ( '<STR_LIT:name>' , self . new_volume . name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . create . assert_called_with ( <EOL> size = self . new_volume . size , <EOL> snapshot_id = None , <EOL> name = self . new_volume . name , <EOL> description = None , <EOL> volume_type = None , <EOL> user_id = None , <EOL> project_id = None , <EOL> availability_zone = None , <EOL> metadata = None , <EOL> imageRef = volume_fakes . image_id , <EOL> source_volid = None , <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_volume_create_image_name ( self ) : <EOL> self . images_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( volume_fakes . IMAGE ) , <EOL> loaded = True , <EOL> ) <EOL> arglist = [ <EOL> '<STR_LIT>' , volume_fakes . image_name , <EOL> '<STR_LIT>' , str ( self . new_volume . size ) , <EOL> self . new_volume . name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:image>' , volume_fakes . image_name ) , <EOL> ( '<STR_LIT:size>' , self . new_volume . size ) , <EOL> ( '<STR_LIT:name>' , self . new_volume . name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . create . assert_called_with ( <EOL> size = self . new_volume . size , <EOL> snapshot_id = None , <EOL> name = self . new_volume . name , <EOL> description = None , <EOL> volume_type = None , <EOL> user_id = None , <EOL> project_id = None , <EOL> availability_zone = None , <EOL> metadata = None , <EOL> imageRef = volume_fakes . image_id , <EOL> source_volid = None <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_volume_create_with_snapshot ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , str ( self . new_volume . size ) , <EOL> '<STR_LIT>' , volume_fakes . snapshot_id , <EOL> self . new_volume . name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:size>' , self . new_volume . size ) , <EOL> ( '<STR_LIT>' , volume_fakes . snapshot_id ) , <EOL> ( '<STR_LIT:name>' , self . new_volume . name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> fake_snapshot = mock . Mock ( ) <EOL> fake_snapshot . id = volume_fakes . snapshot_id <EOL> self . snapshots_mock . get . return_value = fake_snapshot <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . create . assert_called_once_with ( <EOL> size = self . new_volume . size , <EOL> snapshot_id = fake_snapshot . id , <EOL> name = self . new_volume . name , <EOL> description = None , <EOL> volume_type = None , <EOL> user_id = None , <EOL> project_id = None , <EOL> availability_zone = None , <EOL> metadata = None , <EOL> imageRef = None , <EOL> source_volid = None <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> class TestVolumeDelete ( TestVolume ) : <EOL> def setUp ( self ) : <EOL> super ( TestVolumeDelete , self ) . setUp ( ) <EOL> self . volumes_mock . delete . return_value = None <EOL> self . cmd = volume . DeleteVolume ( self . app , None ) <EOL> def test_volume_delete_one_volume ( self ) : <EOL> volumes = self . setup_volumes_mock ( count = <NUM_LIT:1> ) <EOL> arglist = [ <EOL> volumes [ <NUM_LIT:0> ] . id <EOL> ] <EOL> verifylist = [ <EOL> ( "<STR_LIT>" , [ volumes [ <NUM_LIT:0> ] . id ] ) <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . delete . assert_called_with ( volumes [ <NUM_LIT:0> ] . id ) <EOL> self . assertIsNone ( result ) <EOL> def test_volume_delete_multi_volumes ( self ) : <EOL> volumes = self . setup_volumes_mock ( count = <NUM_LIT:3> ) <EOL> arglist = [ v . id for v in volumes ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , arglist ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> calls = [ call ( v . id ) for v in volumes ] <EOL> self . volumes_mock . delete . assert_has_calls ( calls ) <EOL> self . assertIsNone ( result ) <EOL> class TestVolumeList ( TestVolume ) : <EOL> columns = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> def setUp ( self ) : <EOL> super ( TestVolumeList , self ) . setUp ( ) <EOL> self . volumes_mock . list . return_value = [ <EOL> fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( volume_fakes . VOLUME ) , <EOL> loaded = True , <EOL> ) , <EOL> ] <EOL> self . users_mock . get . return_value = [ <EOL> fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . USER ) , <EOL> loaded = True , <EOL> ) , <EOL> ] <EOL> self . projects_mock . get . return_value = [ <EOL> fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) , <EOL> ] <EOL> self . cmd = volume . ListVolume ( self . app , None ) <EOL> def test_volume_list_no_options ( self ) : <EOL> arglist = [ ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:name>' , None ) , <EOL> ( '<STR_LIT:status>' , None ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> server = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> device = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> msg = '<STR_LIT>' % ( server , device ) <EOL> datalist = ( ( <EOL> volume_fakes . volume_id , <EOL> volume_fakes . volume_name , <EOL> volume_fakes . volume_status , <EOL> volume_fakes . volume_size , <EOL> msg , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_volume_list_project ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , identity_fakes . project_name ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:status>' , None ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> server = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> device = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> msg = '<STR_LIT>' % ( server , device ) <EOL> datalist = ( ( <EOL> volume_fakes . volume_id , <EOL> volume_fakes . volume_name , <EOL> volume_fakes . volume_status , <EOL> volume_fakes . volume_size , <EOL> msg , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_volume_list_project_domain ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , identity_fakes . project_name , <EOL> '<STR_LIT>' , identity_fakes . domain_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , identity_fakes . project_name ) , <EOL> ( '<STR_LIT>' , identity_fakes . domain_name ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:status>' , None ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> server = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> device = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> msg = '<STR_LIT>' % ( server , device ) <EOL> datalist = ( ( <EOL> volume_fakes . volume_id , <EOL> volume_fakes . volume_name , <EOL> volume_fakes . volume_status , <EOL> volume_fakes . volume_size , <EOL> msg , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_volume_list_user ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , identity_fakes . user_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:user>' , identity_fakes . user_name ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:status>' , None ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> server = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> device = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> msg = '<STR_LIT>' % ( server , device ) <EOL> datalist = ( ( <EOL> volume_fakes . volume_id , <EOL> volume_fakes . volume_name , <EOL> volume_fakes . volume_status , <EOL> volume_fakes . volume_size , <EOL> msg , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_volume_list_user_domain ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , identity_fakes . user_name , <EOL> '<STR_LIT>' , identity_fakes . domain_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:user>' , identity_fakes . user_name ) , <EOL> ( '<STR_LIT>' , identity_fakes . domain_name ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:status>' , None ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> server = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> device = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> msg = '<STR_LIT>' % ( server , device ) <EOL> datalist = ( ( <EOL> volume_fakes . volume_id , <EOL> volume_fakes . volume_name , <EOL> volume_fakes . volume_status , <EOL> volume_fakes . volume_size , <EOL> msg , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_volume_list_name ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , volume_fakes . volume_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:name>' , volume_fakes . volume_name ) , <EOL> ( '<STR_LIT:status>' , None ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> server = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> device = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> msg = '<STR_LIT>' % ( server , device ) <EOL> datalist = ( ( <EOL> volume_fakes . volume_id , <EOL> volume_fakes . volume_name , <EOL> volume_fakes . volume_status , <EOL> volume_fakes . volume_size , <EOL> msg , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_volume_list_status ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , volume_fakes . volume_status , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:name>' , None ) , <EOL> ( '<STR_LIT:status>' , volume_fakes . volume_status ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> server = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> device = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> msg = '<STR_LIT>' % ( server , device ) <EOL> datalist = ( ( <EOL> volume_fakes . volume_id , <EOL> volume_fakes . volume_name , <EOL> volume_fakes . volume_status , <EOL> volume_fakes . volume_size , <EOL> msg , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_volume_list_all_projects ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT:name>' , None ) , <EOL> ( '<STR_LIT:status>' , None ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> server = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> device = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> msg = '<STR_LIT>' % ( server , device ) <EOL> datalist = ( ( <EOL> volume_fakes . volume_id , <EOL> volume_fakes . volume_name , <EOL> volume_fakes . volume_status , <EOL> volume_fakes . volume_size , <EOL> msg , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_volume_list_long ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:name>' , None ) , <EOL> ( '<STR_LIT:status>' , None ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> collist = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> self . assertEqual ( collist , columns ) <EOL> server = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> device = volume_fakes . volume_attachment_server [ '<STR_LIT>' ] <EOL> msg = '<STR_LIT>' % ( server , device ) <EOL> datalist = ( ( <EOL> volume_fakes . volume_id , <EOL> volume_fakes . volume_name , <EOL> volume_fakes . volume_status , <EOL> volume_fakes . volume_size , <EOL> volume_fakes . volume_type , <EOL> '<STR_LIT>' , <EOL> msg , <EOL> "<STR_LIT>" , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> class TestVolumeShow ( TestVolume ) : <EOL> def setUp ( self ) : <EOL> super ( TestVolumeShow , self ) . setUp ( ) <EOL> self . volumes_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( volume_fakes . VOLUME ) , <EOL> loaded = True ) <EOL> self . cmd = volume . ShowVolume ( self . app , None ) <EOL> def test_volume_show ( self ) : <EOL> arglist = [ <EOL> volume_fakes . volume_id <EOL> ] <EOL> verifylist = [ <EOL> ( "<STR_LIT>" , volume_fakes . volume_id ) <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . get . assert_called_with ( volume_fakes . volume_id ) <EOL> self . assertEqual ( volume_fakes . VOLUME_columns , columns ) <EOL> self . assertEqual ( volume_fakes . VOLUME_data , data ) <EOL> class TestVolumeSet ( TestVolume ) : <EOL> def setUp ( self ) : <EOL> super ( TestVolumeSet , self ) . setUp ( ) <EOL> self . new_volume = volume_fakes . FakeVolume . create_one_volume ( ) <EOL> self . volumes_mock . create . return_value = self . new_volume <EOL> self . cmd = volume . SetVolume ( self . app , None ) <EOL> def test_volume_set_image_property ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> self . new_volume . id , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:a>' , '<STR_LIT>' : '<STR_LIT:b>' } ) , <EOL> ( '<STR_LIT>' , self . new_volume . id ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> self . cmd . take_action ( parsed_args ) <EOL> self . volumes_mock . set_image_metadata . assert_called_with ( <EOL> self . volumes_mock . get ( ) . id , parsed_args . image_property ) <EOL> class TestVolumeUnset ( TestVolume ) : <EOL> def setUp ( self ) : <EOL> super ( TestVolumeUnset , self ) . setUp ( ) <EOL> self . new_volume = volume_fakes . FakeVolume . create_one_volume ( ) <EOL> self . volumes_mock . create . return_value = self . new_volume <EOL> self . cmd_set = volume . SetVolume ( self . app , None ) <EOL> self . cmd_unset = volume . UnsetVolume ( self . app , None ) <EOL> def test_volume_unset_image_property ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> self . new_volume . id , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:a>' , '<STR_LIT>' : '<STR_LIT:b>' } ) , <EOL> ( '<STR_LIT>' , self . new_volume . id ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd_set , arglist , verifylist ) <EOL> self . cmd_set . take_action ( parsed_args ) <EOL> arglist_unset = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> self . new_volume . id , <EOL> ] <EOL> verifylist_unset = [ <EOL> ( '<STR_LIT>' , [ '<STR_LIT>' ] ) , <EOL> ( '<STR_LIT>' , self . new_volume . id ) , <EOL> ] <EOL> parsed_args_unset = self . check_parser ( self . cmd_unset , <EOL> arglist_unset , <EOL> verifylist_unset ) <EOL> self . cmd_unset . take_action ( parsed_args_unset ) <EOL> self . volumes_mock . delete_image_metadata . assert_called_with ( <EOL> self . volumes_mock . get ( ) . id , parsed_args_unset . image_property ) </s>
