<s> import sys <EOL> from mox3 import mox <EOL> from neutronclient . common import exceptions <EOL> from neutronclient . neutron . v2_0 . bgp import speaker as bgp_speaker <EOL> from neutronclient . tests . unit import test_cli20 <EOL> class CLITestV20BGPSpeakerJSON ( test_cli20 . CLITestV20Base ) : <EOL> non_admin_status_resources = [ '<STR_LIT>' ] <EOL> def test_create_bgp_speaker_with_minimal_options ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = bgp_speaker . CreateSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> name = '<STR_LIT>' <EOL> my_id = '<STR_LIT>' <EOL> local_asnum = '<STR_LIT:1>' <EOL> args = [ name , '<STR_LIT>' , local_asnum , ] <EOL> position_names = [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> position_values = [ name , local_asnum , <NUM_LIT:4> ] <EOL> self . _test_create_resource ( resource , cmd , name , my_id , args , <EOL> position_names , position_values ) <EOL> def test_create_ipv4_bgp_speaker_with_all_params ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = bgp_speaker . CreateSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> name = '<STR_LIT>' <EOL> my_id = '<STR_LIT>' <EOL> local_asnum = '<STR_LIT:1>' <EOL> args = [ name , <EOL> '<STR_LIT>' , local_asnum , <EOL> '<STR_LIT>' , '<STR_LIT:4>' , <EOL> '<STR_LIT>' , '<STR_LIT:True>' , <EOL> '<STR_LIT>' , '<STR_LIT:True>' ] <EOL> position_names = [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> position_values = [ name , local_asnum , <NUM_LIT:4> , '<STR_LIT:True>' , '<STR_LIT:True>' ] <EOL> self . _test_create_resource ( resource , cmd , name , my_id , args , <EOL> position_names , position_values ) <EOL> def test_create_ipv6_bgp_speaker_with_all_params ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = bgp_speaker . CreateSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> name = '<STR_LIT>' <EOL> my_id = '<STR_LIT>' <EOL> local_asnum = '<STR_LIT>' <EOL> args = [ name , <EOL> '<STR_LIT>' , local_asnum , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:True>' , <EOL> '<STR_LIT>' , '<STR_LIT:True>' ] <EOL> position_names = [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> position_values = [ name , local_asnum , <NUM_LIT:6> , '<STR_LIT:True>' , '<STR_LIT:True>' ] <EOL> self . _test_create_resource ( resource , cmd , name , my_id , args , <EOL> position_names , position_values ) <EOL> def test_create_bgp_speaker_with_invalid_min_local_asnum ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = bgp_speaker . CreateSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> name = '<STR_LIT>' <EOL> my_id = '<STR_LIT>' <EOL> local_asnum = '<STR_LIT:0>' <EOL> args = [ name , <EOL> '<STR_LIT>' , local_asnum ] <EOL> position_names = [ '<STR_LIT:name>' , '<STR_LIT>' ] <EOL> position_values = [ name , local_asnum ] <EOL> exc = self . assertRaises ( exceptions . CommandError , <EOL> self . _test_create_resource , <EOL> resource , cmd , name , my_id , args , <EOL> position_names , position_values ) <EOL> self . assertEqual ( '<STR_LIT>' % <EOL> ( bgp_speaker . MIN_AS_NUM , bgp_speaker . MAX_AS_NUM ) , <EOL> str ( exc ) ) <EOL> def test_create_bgp_speaker_with_invalid_max_local_asnum ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = bgp_speaker . CreateSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> name = '<STR_LIT>' <EOL> my_id = '<STR_LIT>' <EOL> local_asnum = '<STR_LIT>' <EOL> args = [ name , <EOL> '<STR_LIT>' , local_asnum ] <EOL> position_names = [ '<STR_LIT:name>' , '<STR_LIT>' , ] <EOL> position_values = [ name , local_asnum , ] <EOL> exc = self . assertRaises ( exceptions . CommandError , <EOL> self . _test_create_resource , <EOL> resource , cmd , name , my_id , args , <EOL> position_names , position_values ) <EOL> self . assertEqual ( '<STR_LIT>' % <EOL> ( bgp_speaker . MIN_AS_NUM , bgp_speaker . MAX_AS_NUM ) , <EOL> str ( exc ) ) <EOL> def test_update_bgp_speaker ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = bgp_speaker . UpdateSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:True>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:False>' ] , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' , <EOL> '<STR_LIT>' : <EOL> '<STR_LIT:False>' } ) <EOL> def test_update_bgp_speaker_exception ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = bgp_speaker . UpdateSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . assertRaises ( exceptions . CommandError , <EOL> self . _test_update_resource , <EOL> resource , cmd , '<STR_LIT>' , [ '<STR_LIT>' ] , { } ) <EOL> def test_list_bgp_speaker ( self ) : <EOL> resources = "<STR_LIT>" <EOL> cmd = bgp_speaker . ListSpeakers ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . _test_list_resources ( resources , cmd , True ) <EOL> def test_list_bgp_speaker_pagination ( self ) : <EOL> cmd = bgp_speaker . ListSpeakers ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . mox . StubOutWithMock ( bgp_speaker . ListSpeakers , <EOL> "<STR_LIT>" ) <EOL> bgp_speaker . ListSpeakers . extend_list ( mox . IsA ( list ) , <EOL> mox . IgnoreArg ( ) ) <EOL> self . _test_list_resources_with_pagination ( "<STR_LIT>" , <EOL> cmd ) <EOL> self . mox . VerifyAll ( ) <EOL> self . mox . UnsetStubs ( ) <EOL> def test_list_bgp_speaker_sort ( self ) : <EOL> resources = "<STR_LIT>" <EOL> cmd = bgp_speaker . ListSpeakers ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . _test_list_resources ( resources , cmd , <EOL> sort_key = [ "<STR_LIT:name>" , "<STR_LIT:id>" ] , <EOL> sort_dir = [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_list_bgp_speaker_limit ( self ) : <EOL> resources = "<STR_LIT>" <EOL> cmd = bgp_speaker . ListSpeakers ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . _test_list_resources ( resources , cmd , page_size = <NUM_LIT:1000> ) <EOL> def test_show_bgp_speaker ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = bgp_speaker . ShowSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> args = [ '<STR_LIT>' , '<STR_LIT:id>' , '<STR_LIT>' , '<STR_LIT:name>' , self . test_id ] <EOL> self . _test_show_resource ( resource , cmd , self . test_id , args , <EOL> [ '<STR_LIT:id>' , '<STR_LIT:name>' ] ) <EOL> def test_delete_bgp_speaker ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = bgp_speaker . DeleteSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> myid = '<STR_LIT>' <EOL> args = [ myid ] <EOL> self . _test_delete_resource ( resource , cmd , myid , args ) <EOL> def _test_add_remove_peer ( self , action , cmd , args ) : <EOL> """<STR_LIT>""" <EOL> resource = '<STR_LIT>' <EOL> subcmd = '<STR_LIT>' % action <EOL> body = { '<STR_LIT>' : '<STR_LIT>' } <EOL> if action == '<STR_LIT>' : <EOL> retval = { '<STR_LIT>' : '<STR_LIT>' } <EOL> else : <EOL> retval = None <EOL> self . _test_update_resource_action ( resource , cmd , '<STR_LIT>' , <EOL> subcmd , args , body , retval ) <EOL> def test_add_peer_to_bgp_speaker ( self ) : <EOL> cmd = bgp_speaker . AddPeerToSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> args = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . _test_add_remove_peer ( '<STR_LIT>' , cmd , args ) <EOL> def test_remove_peer_from_bgp_speaker ( self ) : <EOL> cmd = bgp_speaker . RemovePeerFromSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> args = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . _test_add_remove_peer ( '<STR_LIT>' , cmd , args ) <EOL> def _test_add_remove_network ( self , action , cmd , args ) : <EOL> resource = '<STR_LIT>' <EOL> subcmd = '<STR_LIT>' % action <EOL> body = { '<STR_LIT>' : '<STR_LIT>' } <EOL> if action == '<STR_LIT>' : <EOL> retval = { '<STR_LIT>' : '<STR_LIT>' } <EOL> else : <EOL> retval = None <EOL> self . _test_update_resource_action ( resource , cmd , '<STR_LIT>' , <EOL> subcmd , args , body , retval ) <EOL> def test_add_network_to_bgp_speaker ( self ) : <EOL> cmd = bgp_speaker . AddNetworkToSpeaker ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> args = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . _test_add_remove_network ( '<STR_LIT>' , cmd , args ) <EOL> def test_remove_network_from_bgp_speaker ( self ) : <EOL> cmd = bgp_speaker . RemoveNetworkFromSpeaker ( <EOL> test_cli20 . MyApp ( sys . stdout ) , None ) <EOL> args = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . _test_add_remove_network ( '<STR_LIT>' , cmd , args ) <EOL> def test_list_routes_advertised_by_a_bgp_speaker ( self ) : <EOL> resources = '<STR_LIT>' <EOL> cmd = bgp_speaker . ListRoutesAdvertisedBySpeaker ( <EOL> test_cli20 . MyApp ( sys . stdout ) , None ) <EOL> bs_id = '<STR_LIT>' <EOL> path = ( ( self . client . bgp_speaker_path + '<STR_LIT>' ) % <EOL> bs_id ) <EOL> self . _test_list_resources ( resources , cmd , base_args = [ bs_id ] , <EOL> path = path ) </s>
