<s> import copy <EOL> from keystoneauth1 import exceptions as ks_exc <EOL> from openstackclient . identity . v2_0 import project <EOL> from openstackclient . tests import fakes <EOL> from openstackclient . tests . identity . v2_0 import fakes as identity_fakes <EOL> class TestProject ( identity_fakes . TestIdentityv2 ) : <EOL> def setUp ( self ) : <EOL> super ( TestProject , self ) . setUp ( ) <EOL> self . projects_mock = self . app . client_manager . identity . tenants <EOL> self . projects_mock . reset_mock ( ) <EOL> class TestProjectCreate ( TestProject ) : <EOL> columns = ( <EOL> '<STR_LIT:description>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' , <EOL> '<STR_LIT:name>' , <EOL> ) <EOL> datalist = ( <EOL> identity_fakes . project_description , <EOL> True , <EOL> identity_fakes . project_id , <EOL> identity_fakes . project_name , <EOL> ) <EOL> def setUp ( self ) : <EOL> super ( TestProjectCreate , self ) . setUp ( ) <EOL> self . projects_mock . create . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) <EOL> self . cmd = project . CreateProject ( self . app , None ) <EOL> def test_project_create_no_options ( self ) : <EOL> arglist = [ <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:name>' , identity_fakes . project_name ) , <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:description>' : None , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> self . projects_mock . create . assert_called_with ( <EOL> identity_fakes . project_name , <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_project_create_description ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:description>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:name>' , identity_fakes . project_name ) , <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:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> self . projects_mock . create . assert_called_with ( <EOL> identity_fakes . project_name , <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_project_create_enable ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT:name>' , identity_fakes . project_name ) , <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:description>' : None , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> self . projects_mock . create . assert_called_with ( <EOL> identity_fakes . project_name , <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_project_create_disable ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT:name>' , identity_fakes . project_name ) , <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:description>' : None , <EOL> '<STR_LIT>' : False , <EOL> } <EOL> self . projects_mock . create . assert_called_with ( <EOL> identity_fakes . project_name , <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_project_create_property ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> ( '<STR_LIT:name>' , identity_fakes . project_name ) , <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:description>' : None , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . projects_mock . create . assert_called_with ( <EOL> identity_fakes . project_name , <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_project_create_or_show_exists ( self ) : <EOL> def _raise_conflict ( * args , ** kwargs ) : <EOL> raise ks_exc . Conflict ( None ) <EOL> self . projects_mock . create . side_effect = _raise_conflict <EOL> self . projects_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:name>' , identity_fakes . project_name ) , <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> self . projects_mock . get . assert_called_with ( identity_fakes . project_name ) <EOL> kwargs = { <EOL> '<STR_LIT:description>' : None , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> self . projects_mock . create . assert_called_with ( <EOL> identity_fakes . project_name , <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> def test_project_create_or_show_not_exists ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:name>' , identity_fakes . project_name ) , <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> '<STR_LIT:description>' : None , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> self . projects_mock . create . assert_called_with ( <EOL> identity_fakes . project_name , <EOL> ** kwargs <EOL> ) <EOL> self . assertEqual ( self . columns , columns ) <EOL> self . assertEqual ( self . datalist , data ) <EOL> class TestProjectDelete ( TestProject ) : <EOL> def setUp ( self ) : <EOL> super ( TestProjectDelete , self ) . setUp ( ) <EOL> self . projects_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) <EOL> self . projects_mock . delete . return_value = None <EOL> self . cmd = project . DeleteProject ( self . app , None ) <EOL> def test_project_delete_no_options ( self ) : <EOL> arglist = [ <EOL> identity_fakes . project_id , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , [ identity_fakes . project_id ] ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> self . projects_mock . delete . assert_called_with ( <EOL> identity_fakes . project_id , <EOL> ) <EOL> self . assertIsNone ( result ) <EOL> class TestProjectList ( TestProject ) : <EOL> def setUp ( self ) : <EOL> super ( TestProjectList , self ) . setUp ( ) <EOL> self . projects_mock . list . return_value = [ <EOL> fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) , <EOL> ] <EOL> self . cmd = project . ListProject ( self . app , None ) <EOL> def test_project_list_no_options ( self ) : <EOL> arglist = [ ] <EOL> verifylist = [ ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . projects_mock . list . assert_called_with ( ) <EOL> collist = ( '<STR_LIT>' , '<STR_LIT:Name>' ) <EOL> self . assertEqual ( collist , columns ) <EOL> datalist = ( ( <EOL> identity_fakes . project_id , <EOL> identity_fakes . project_name , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> def test_project_list_long ( self ) : <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> self . projects_mock . list . assert_called_with ( ) <EOL> collist = ( '<STR_LIT>' , '<STR_LIT:Name>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( collist , columns ) <EOL> datalist = ( ( <EOL> identity_fakes . project_id , <EOL> identity_fakes . project_name , <EOL> identity_fakes . project_description , <EOL> True , <EOL> ) , ) <EOL> self . assertEqual ( datalist , tuple ( data ) ) <EOL> class TestProjectSet ( TestProject ) : <EOL> def setUp ( self ) : <EOL> super ( TestProjectSet , self ) . setUp ( ) <EOL> self . projects_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) <EOL> self . projects_mock . update . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) <EOL> self . cmd = project . SetProject ( self . app , None ) <EOL> def test_project_set_no_options ( self ) : <EOL> arglist = [ <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , identity_fakes . project_name ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> self . assertIsNone ( result ) <EOL> def test_project_set_name ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , identity_fakes . project_name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT:description>' : identity_fakes . project_description , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . projects_mock . update . assert_called_with ( <EOL> identity_fakes . project_id , <EOL> ** kwargs <EOL> ) <EOL> self . assertIsNone ( result ) <EOL> def test_project_set_description ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT:description>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , identity_fakes . project_name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : identity_fakes . project_name , <EOL> } <EOL> self . projects_mock . update . assert_called_with ( <EOL> identity_fakes . project_id , <EOL> ** kwargs <EOL> ) <EOL> self . assertIsNone ( result ) <EOL> def test_project_set_enable ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , identity_fakes . project_name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT:description>' : identity_fakes . project_description , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : identity_fakes . project_name , <EOL> } <EOL> self . projects_mock . update . assert_called_with ( <EOL> identity_fakes . project_id , <EOL> ** kwargs <EOL> ) <EOL> self . assertIsNone ( result ) <EOL> def test_project_set_disable ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , identity_fakes . project_name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT:description>' : identity_fakes . project_description , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : identity_fakes . project_name , <EOL> } <EOL> self . projects_mock . update . assert_called_with ( <EOL> identity_fakes . project_id , <EOL> ** kwargs <EOL> ) <EOL> self . assertIsNone ( result ) <EOL> def test_project_set_property ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> ( '<STR_LIT>' , identity_fakes . project_name ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT:description>' : identity_fakes . project_description , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : identity_fakes . project_name , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . projects_mock . update . assert_called_with ( <EOL> identity_fakes . project_id , <EOL> ** kwargs <EOL> ) <EOL> self . assertIsNone ( result ) <EOL> class TestProjectShow ( TestProject ) : <EOL> def setUp ( self ) : <EOL> super ( TestProjectShow , self ) . setUp ( ) <EOL> self . projects_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( identity_fakes . PROJECT ) , <EOL> loaded = True , <EOL> ) <EOL> self . cmd = project . ShowProject ( self . app , None ) <EOL> def test_project_show ( self ) : <EOL> arglist = [ <EOL> identity_fakes . project_id , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , identity_fakes . project_id ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> columns , data = self . cmd . take_action ( parsed_args ) <EOL> self . projects_mock . get . assert_called_with ( <EOL> identity_fakes . project_id , <EOL> ) <EOL> collist = ( '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> self . assertEqual ( collist , columns ) <EOL> datalist = ( <EOL> identity_fakes . project_description , <EOL> True , <EOL> identity_fakes . project_id , <EOL> identity_fakes . project_name , <EOL> '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( datalist , data ) <EOL> class TestProjectUnset ( TestProject ) : <EOL> def setUp ( self ) : <EOL> super ( TestProjectUnset , self ) . setUp ( ) <EOL> project_dict = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> project_dict . update ( identity_fakes . PROJECT ) <EOL> self . projects_mock . get . return_value = fakes . FakeResource ( <EOL> None , <EOL> copy . deepcopy ( project_dict ) , <EOL> loaded = True , <EOL> ) <EOL> self . cmd = project . UnsetProject ( self . app , None ) <EOL> def test_project_unset_key ( self ) : <EOL> arglist = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> identity_fakes . project_name , <EOL> ] <EOL> verifylist = [ <EOL> ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> ] <EOL> parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) <EOL> result = self . cmd . take_action ( parsed_args ) <EOL> kwargs = { <EOL> '<STR_LIT:description>' : identity_fakes . project_description , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT:id>' : identity_fakes . project_id , <EOL> '<STR_LIT:name>' : identity_fakes . project_name , <EOL> } <EOL> self . projects_mock . update . assert_called_with ( <EOL> identity_fakes . project_id , <EOL> ** kwargs <EOL> ) <EOL> self . assertIsNone ( result ) </s>
