<s> import copy <EOL> import mock <EOL> from openstackclient . api import object_store_v1 as object_store <EOL> from openstackclient . object . v1 import container <EOL> from openstackclient . tests . object . v1 import fakes as object_fakes <EOL> AUTH_TOKEN = "<STR_LIT>" <EOL> AUTH_URL = "<STR_LIT>" <EOL> class FakeClient ( object ) : <EOL> def __init__ ( self , endpoint = None , ** kwargs ) : <EOL> self . endpoint = AUTH_URL <EOL> self . token = AUTH_TOKEN <EOL> class TestContainer ( object_fakes . TestObjectv1 ) : <EOL> columns = ( '<STR_LIT:Name>' , ) <EOL> def setUp ( self ) : <EOL> super ( TestContainer , self ) . setUp ( ) <EOL> self . app . client_manager . object_store = object_store . APIv1 ( <EOL> session = mock . Mock ( ) , <EOL> service_type = "<STR_LIT>" , <EOL> ) <EOL> self . api = self . app . client_manager . object_store <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> class TestContainerDelete ( TestContainer ) : <EOL> def setUp ( self ) : <EOL> super ( TestContainerDelete , self ) . setUp ( ) <EOL> self . cmd = container . DeleteContainer ( self . app , None ) <EOL> def test_container_delete ( self , c_mock , o_list_mock , o_delete_mock ) : <EOL> c_mock . return_value = None <EOL> arglist = [ <EOL> object_fakes . container_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , [ object_fakes . container_name ] ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> self . assertIsNone ( self . cmd . take_action ( parsed_args ) ) <EOL> kwargs = { } <EOL> c_mock . assert_called_with ( <EOL> container = object_fakes . container_name , <EOL> ** kwargs <EOL> ) <EOL> self . assertFalse ( o_list_mock . called ) <EOL> self . assertFalse ( o_delete_mock . called ) <EOL> def test_recursive_delete ( self , c_mock , o_list_mock , o_delete_mock ) : <EOL> c_mock . return_value = None <EOL> o_list_mock . return_value = [ object_fakes . OBJECT ] <EOL> o_delete_mock . return_value = None <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> object_fakes . container_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , [ object_fakes . container_name ] ) , <EOL> ( '<STR_LIT>' , True ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> self . assertIsNone ( self . cmd . take_action ( parsed_args ) ) <EOL> kwargs = { } <EOL> c_mock . assert_called_with ( <EOL> container = object_fakes . container_name , <EOL> ** kwargs <EOL> ) <EOL> o_list_mock . assert_called_with ( container = object_fakes . container_name ) <EOL> o_delete_mock . assert_called_with ( <EOL> container = object_fakes . container_name , <EOL> object = object_fakes . OBJECT [ '<STR_LIT:name>' ] , <EOL> ) <EOL> def test_r_delete ( self , c_mock , o_list_mock , o_delete_mock ) : <EOL> c_mock . return_value = None <EOL> o_list_mock . return_value = [ object_fakes . OBJECT ] <EOL> o_delete_mock . return_value = None <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> object_fakes . container_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , [ object_fakes . container_name ] ) , <EOL> ( '<STR_LIT>' , True ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> self . assertIsNone ( self . cmd . take_action ( parsed_args ) ) <EOL> kwargs = { } <EOL> c_mock . assert_called_with ( <EOL> container = object_fakes . container_name , <EOL> ** kwargs <EOL> ) <EOL> o_list_mock . assert_called_with ( container = object_fakes . container_name ) <EOL> o_delete_mock . assert_called_with ( <EOL> container = object_fakes . container_name , <EOL> object = object_fakes . OBJECT [ '<STR_LIT:name>' ] , <EOL> ) <EOL> @ mock . patch ( <EOL> '<STR_LIT>' <EOL> ) <EOL> class TestContainerList ( TestContainer ) : <EOL> def setUp ( self ) : <EOL> super ( TestContainerList , self ) . setUp ( ) <EOL> self . cmd = container . ListContainer ( self . app , None ) <EOL> def test_object_list_containers_no_options ( self , c_mock ) : <EOL> c_mock . return_value = [ <EOL> copy . deepcopy ( object_fakes . CONTAINER ) , <EOL> copy . deepcopy ( object_fakes . CONTAINER_3 ) , <EOL> copy . deepcopy ( object_fakes . CONTAINER_2 ) , <EOL> ] <EOL> arglist = [ ] <EOL> verifylist = [ ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> } <EOL> c_mock . assert_called_with ( <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> datalist = ( <EOL> ( object_fakes . container_name , ) , <EOL> ( object_fakes . container_name_3 , ) , <EOL> ( object_fakes . container_name_2 , ) , <EOL> ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_object_list_containers_prefix ( self , c_mock ) : <EOL> c_mock . return_value = [ <EOL> copy . deepcopy ( object_fakes . CONTAINER ) , <EOL> copy . deepcopy ( object_fakes . CONTAINER_3 ) , <EOL> ] <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> c_mock . assert_called_with ( <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> datalist = ( <EOL> ( object_fakes . container_name , ) , <EOL> ( object_fakes . container_name_3 , ) , <EOL> ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_object_list_containers_marker ( self , c_mock ) : <EOL> c_mock . return_value = [ <EOL> copy . deepcopy ( object_fakes . CONTAINER ) , <EOL> copy . deepcopy ( object_fakes . CONTAINER_3 ) , <EOL> ] <EOL> arglist = [ <EOL> '<STR_LIT>' , object_fakes . container_name , <EOL> '<STR_LIT>' , object_fakes . container_name_3 , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , object_fakes . container_name ) , <EOL> ( '<STR_LIT>' , object_fakes . container_name_3 ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT>' : object_fakes . container_name , <EOL> '<STR_LIT>' : object_fakes . container_name_3 , <EOL> } <EOL> c_mock . assert_called_with ( <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> datalist = ( <EOL> ( object_fakes . container_name , ) , <EOL> ( object_fakes . container_name_3 , ) , <EOL> ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_object_list_containers_limit ( self , c_mock ) : <EOL> c_mock . return_value = [ <EOL> copy . deepcopy ( object_fakes . CONTAINER ) , <EOL> copy . deepcopy ( object_fakes . CONTAINER_3 ) , <EOL> ] <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT:2>' , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , <NUM_LIT:2> ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> } <EOL> c_mock . assert_called_with ( <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> datalist = ( <EOL> ( object_fakes . container_name , ) , <EOL> ( object_fakes . container_name_3 , ) , <EOL> ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_object_list_containers_long ( self , c_mock ) : <EOL> c_mock . return_value = [ <EOL> copy . deepcopy ( object_fakes . CONTAINER ) , <EOL> copy . deepcopy ( object_fakes . CONTAINER_3 ) , <EOL> ] <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , True ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> } <EOL> c_mock . assert_called_with ( <EOL> ** kwargs <EOL> ) <EOL> collist = ( '<STR_LIT:Name>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( collist , columns ) <EOL> datalist = ( <EOL> ( <EOL> object_fakes . container_name , <EOL> object_fakes . container_bytes , <EOL> object_fakes . container_count , <EOL> ) , <EOL> ( <EOL> object_fakes . container_name_3 , <EOL> object_fakes . container_bytes * <NUM_LIT:3> , <EOL> object_fakes . container_count * <NUM_LIT:3> , <EOL> ) , <EOL> ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_object_list_containers_all ( self , c_mock ) : <EOL> c_mock . return_value = [ <EOL> copy . deepcopy ( object_fakes . CONTAINER ) , <EOL> copy . deepcopy ( object_fakes . CONTAINER_2 ) , <EOL> copy . deepcopy ( object_fakes . CONTAINER_3 ) , <EOL> ] <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:all>' , True ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT>' : True , <EOL> } <EOL> c_mock . assert_called_with ( <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> datalist = ( <EOL> ( object_fakes . container_name , ) , <EOL> ( object_fakes . container_name_2 , ) , <EOL> ( object_fakes . container_name_3 , ) , <EOL> ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> @ mock . patch ( <EOL> '<STR_LIT>' <EOL> ) <EOL> class TestContainerShow ( TestContainer ) : <EOL> def setUp ( self ) : <EOL> super ( TestContainerShow , self ) . setUp ( ) <EOL> self . cmd = container . ShowContainer ( self . app , None ) <EOL> def test_container_show ( self , c_mock ) : <EOL> c_mock . return_value = copy . deepcopy ( object_fakes . CONTAINER ) <EOL> arglist = [ <EOL> object_fakes . container_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , object_fakes . container_name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> } <EOL> c_mock . assert_called_with ( <EOL> container = object_fakes . container_name , <EOL> ** kwargs <EOL> ) <EOL> collist = ( '<STR_LIT>' , '<STR_LIT:count>' , '<STR_LIT:name>' ) <EOL> self . assertEqual ( collist , columns ) <EOL> datalist = ( <EOL> object_fakes . container_bytes , <EOL> object_fakes . container_count , <EOL> object_fakes . container_name , <EOL> ) <EOL> self . assertEqual ( datalist , data ) </s>
