<s> import sys <EOL> from neutronclient . neutron . v2_0 . fw import firewallrule <EOL> from neutronclient . tests . unit import test_cli20 <EOL> class CLITestV20FirewallRuleJSON ( test_cli20 . CLITestV20Base ) : <EOL> def _test_create_firewall_rule_with_mandatory_params ( self , enabled ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = firewallrule . CreateFirewallRule ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> tenant_id = '<STR_LIT>' <EOL> name = '<STR_LIT>' <EOL> my_id = '<STR_LIT>' <EOL> protocol = '<STR_LIT>' <EOL> action = '<STR_LIT>' <EOL> ip_version = <NUM_LIT:4> <EOL> args = [ '<STR_LIT>' , tenant_id , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , protocol , <EOL> '<STR_LIT>' , action , <EOL> '<STR_LIT>' , enabled ] <EOL> position_names = [ ] <EOL> position_values = [ ] <EOL> self . _test_create_resource ( resource , cmd , name , my_id , args , <EOL> position_names , position_values , <EOL> protocol = protocol , action = action , <EOL> enabled = enabled , tenant_id = tenant_id , <EOL> ip_version = ip_version ) <EOL> def test_create_enabled_firewall_rule_with_mandatory_params_lcase ( self ) : <EOL> self . _test_create_firewall_rule_with_mandatory_params ( enabled = '<STR_LIT:true>' ) <EOL> def test_create_disabled_firewall_rule_with_mandatory_params_lcase ( self ) : <EOL> self . _test_create_firewall_rule_with_mandatory_params ( enabled = '<STR_LIT:false>' ) <EOL> def test_create_enabled_firewall_rule_with_mandatory_params ( self ) : <EOL> self . _test_create_firewall_rule_with_mandatory_params ( enabled = '<STR_LIT:True>' ) <EOL> def test_create_disabled_firewall_rule_with_mandatory_params ( self ) : <EOL> self . _test_create_firewall_rule_with_mandatory_params ( enabled = '<STR_LIT:False>' ) <EOL> def _setup_create_firewall_rule_with_all_params ( <EOL> self , protocol = '<STR_LIT>' , protocol_cli = None , <EOL> action = '<STR_LIT>' , action_cli = None , ip_version = '<STR_LIT:4>' ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = firewallrule . CreateFirewallRule ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> name = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> source_ip = '<STR_LIT>' <EOL> destination_ip = '<STR_LIT>' <EOL> source_port = '<STR_LIT>' <EOL> destination_port = '<STR_LIT>' <EOL> tenant_id = '<STR_LIT>' <EOL> my_id = '<STR_LIT>' <EOL> enabled = '<STR_LIT:True>' <EOL> args = [ '<STR_LIT>' , description , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , protocol_cli or protocol , <EOL> '<STR_LIT>' , ip_version , <EOL> '<STR_LIT>' , source_ip , <EOL> '<STR_LIT>' , destination_ip , <EOL> '<STR_LIT>' , source_port , <EOL> '<STR_LIT>' , destination_port , <EOL> '<STR_LIT>' , action_cli or action , <EOL> '<STR_LIT>' , enabled , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , tenant_id ] <EOL> position_names = [ ] <EOL> position_values = [ ] <EOL> if protocol == '<STR_LIT>' : <EOL> protocol = None <EOL> if ip_version == '<STR_LIT:4>' or ip_version == '<STR_LIT>' : <EOL> self . _test_create_resource ( resource , cmd , name , my_id , args , <EOL> position_names , position_values , <EOL> description = description , shared = True , <EOL> protocol = protocol , <EOL> ip_version = int ( ip_version ) , <EOL> source_ip_address = source_ip , <EOL> destination_ip_address = destination_ip , <EOL> source_port = source_port , <EOL> destination_port = destination_port , <EOL> action = action , enabled = '<STR_LIT:True>' , <EOL> tenant_id = tenant_id ) <EOL> else : <EOL> self . assertRaises ( SystemExit , self . _test_create_resource , <EOL> resource , cmd , name , my_id , args , <EOL> position_names , position_values , <EOL> ip_version = int ( ip_version ) , <EOL> source_ip_address = source_ip , <EOL> destination_ip_address = destination_ip , <EOL> source_port = source_port , <EOL> destination_port = destination_port , <EOL> action = action , enabled = '<STR_LIT:True>' , <EOL> tenant_id = tenant_id ) <EOL> def test_create_firewall_rule_with_all_params ( self ) : <EOL> self . _setup_create_firewall_rule_with_all_params ( ) <EOL> def test_create_firewall_rule_with_proto_any ( self ) : <EOL> self . _setup_create_firewall_rule_with_all_params ( protocol = '<STR_LIT>' ) <EOL> def test_create_firewall_rule_with_IP_version_6 ( self ) : <EOL> self . _setup_create_firewall_rule_with_all_params ( ip_version = '<STR_LIT>' ) <EOL> def test_create_firewall_rule_with_invalid_IP_version ( self ) : <EOL> self . _setup_create_firewall_rule_with_all_params ( ip_version = '<STR_LIT:5>' ) <EOL> def test_create_firewall_rule_with_proto_action_upper_capitalized ( self ) : <EOL> for protocol in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . _setup_create_firewall_rule_with_all_params ( <EOL> protocol = protocol . lower ( ) , <EOL> protocol_cli = protocol ) <EOL> for action in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . _setup_create_firewall_rule_with_all_params ( <EOL> action = action . lower ( ) , <EOL> action_cli = action ) <EOL> def test_list_firewall_rules ( self ) : <EOL> resources = "<STR_LIT>" <EOL> cmd = firewallrule . ListFirewallRule ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . _test_list_resources ( resources , cmd , True ) <EOL> def test_list_firewall_rules_pagination ( self ) : <EOL> resources = "<STR_LIT>" <EOL> cmd = firewallrule . ListFirewallRule ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . _test_list_resources_with_pagination ( resources , cmd ) <EOL> def test_list_firewall_rules_sort ( self ) : <EOL> resources = "<STR_LIT>" <EOL> cmd = firewallrule . ListFirewallRule ( 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_firewall_rules_limit ( self ) : <EOL> resources = "<STR_LIT>" <EOL> cmd = firewallrule . ListFirewallRule ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . _test_list_resources ( resources , cmd , page_size = <NUM_LIT:1000> ) <EOL> def test_show_firewall_rule_id ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = firewallrule . ShowFirewallRule ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> args = [ '<STR_LIT>' , '<STR_LIT:id>' , self . test_id ] <EOL> self . _test_show_resource ( resource , cmd , self . test_id , args , [ '<STR_LIT:id>' ] ) <EOL> def test_show_firewall_rule_id_name ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = firewallrule . ShowFirewallRule ( 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 , <EOL> args , [ '<STR_LIT:id>' , '<STR_LIT:name>' ] ) <EOL> def test_update_firewall_rule ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = firewallrule . UpdateFirewallRule ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , } ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> { '<STR_LIT>' : None , } ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> { '<STR_LIT:description>' : '<STR_LIT>' , } ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:False>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT:False>' , } ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> { '<STR_LIT:action>' : '<STR_LIT>' , } ) <EOL> self . _test_update_resource ( resource , cmd , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:false>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT:false>' , } ) <EOL> def test_delete_firewall_rule ( self ) : <EOL> resource = '<STR_LIT>' <EOL> cmd = firewallrule . DeleteFirewallRule ( test_cli20 . MyApp ( sys . stdout ) , <EOL> None ) <EOL> my_id = '<STR_LIT>' <EOL> args = [ my_id ] <EOL> self . _test_delete_resource ( resource , cmd , my_id , args ) </s>
