@@ -532,31 +532,46 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
532532 _security_group_rules = [_security_group_rule_tcp ,
533533 _security_group_rule_icmp ]
534534
535- expected_columns_with_group = (
535+ expected_columns_with_group_and_long = (
536536 'ID' ,
537537 'IP Protocol' ,
538538 'IP Range' ,
539539 'Port Range' ,
540+ 'Direction' ,
541+ 'Ethertype' ,
540542 'Remote Security Group' ,
541543 )
542- expected_columns_no_group = \
543- expected_columns_with_group + ('Security Group' ,)
544+ expected_columns_no_group = (
545+ 'ID' ,
546+ 'IP Protocol' ,
547+ 'IP Range' ,
548+ 'Port Range' ,
549+ 'Remote Security Group' ,
550+ 'Security Group' ,
551+ )
544552
545- expected_data_with_group = []
553+ expected_data_with_group_and_long = []
546554 expected_data_no_group = []
547555 for _security_group_rule in _security_group_rules :
548- expected_rule_with_group = (
556+ expected_data_with_group_and_long . append ( (
549557 _security_group_rule .id ,
550558 _security_group_rule .protocol ,
551559 _security_group_rule .remote_ip_prefix ,
552560 security_group_rule ._format_network_port_range (
553561 _security_group_rule ),
562+ _security_group_rule .direction ,
563+ _security_group_rule .ethertype ,
554564 _security_group_rule .remote_group_id ,
555- )
556- expected_rule_no_group = expected_rule_with_group + \
557- (_security_group_rule .security_group_id ,)
558- expected_data_with_group .append (expected_rule_with_group )
559- expected_data_no_group .append (expected_rule_no_group )
565+ ))
566+ expected_data_no_group .append ((
567+ _security_group_rule .id ,
568+ _security_group_rule .protocol ,
569+ _security_group_rule .remote_ip_prefix ,
570+ security_group_rule ._format_network_port_range (
571+ _security_group_rule ),
572+ _security_group_rule .remote_group_id ,
573+ _security_group_rule .security_group_id ,
574+ ))
560575
561576 def setUp (self ):
562577 super (TestListSecurityGroupRuleNetwork , self ).setUp ()
@@ -570,7 +585,7 @@ def setUp(self):
570585 self .cmd = security_group_rule .ListSecurityGroupRule (
571586 self .app , self .namespace )
572587
573- def test_list_no_group (self ):
588+ def test_list_default (self ):
574589 self ._security_group_rule_tcp .port_range_min = 80
575590 parsed_args = self .check_parser (self .cmd , [], [])
576591
@@ -580,12 +595,14 @@ def test_list_no_group(self):
580595 self .assertEqual (self .expected_columns_no_group , columns )
581596 self .assertEqual (self .expected_data_no_group , list (data ))
582597
583- def test_list_with_group (self ):
598+ def test_list_with_group_and_long (self ):
584599 self ._security_group_rule_tcp .port_range_min = 80
585600 arglist = [
601+ '--long' ,
586602 self ._security_group .id ,
587603 ]
588604 verifylist = [
605+ ('long' , True ),
589606 ('group' , self ._security_group .id ),
590607 ]
591608 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
@@ -595,8 +612,24 @@ def test_list_with_group(self):
595612 self .network .security_group_rules .assert_called_once_with (** {
596613 'security_group_id' : self ._security_group .id ,
597614 })
598- self .assertEqual (self .expected_columns_with_group , columns )
599- self .assertEqual (self .expected_data_with_group , list (data ))
615+ self .assertEqual (self .expected_columns_with_group_and_long , columns )
616+ self .assertEqual (self .expected_data_with_group_and_long , list (data ))
617+
618+ def test_list_with_ignored_options (self ):
619+ self ._security_group_rule_tcp .port_range_min = 80
620+ arglist = [
621+ '--all-projects' ,
622+ ]
623+ verifylist = [
624+ ('all_projects' , True ),
625+ ]
626+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
627+
628+ columns , data = self .cmd .take_action (parsed_args )
629+
630+ self .network .security_group_rules .assert_called_once_with (** {})
631+ self .assertEqual (self .expected_columns_no_group , columns )
632+ self .assertEqual (self .expected_data_no_group , list (data ))
600633
601634
602635class TestListSecurityGroupRuleCompute (TestSecurityGroupRuleCompute ):
@@ -665,11 +698,13 @@ def setUp(self):
665698 # Get the command object to test
666699 self .cmd = security_group_rule .ListSecurityGroupRule (self .app , None )
667700
668- def test_list_no_group (self ):
701+ def test_list_default (self ):
669702 parsed_args = self .check_parser (self .cmd , [], [])
670703
671704 columns , data = self .cmd .take_action (parsed_args )
672- self .compute .security_groups .list .assert_called_once_with ()
705+ self .compute .security_groups .list .assert_called_once_with (
706+ search_opts = {'all_tenants' : False }
707+ )
673708 self .assertEqual (self .expected_columns_no_group , columns )
674709 self .assertEqual (self .expected_data_no_group , list (data ))
675710
@@ -689,6 +724,38 @@ def test_list_with_group(self):
689724 self .assertEqual (self .expected_columns_with_group , columns )
690725 self .assertEqual (self .expected_data_with_group , list (data ))
691726
727+ def test_list_all_projects (self ):
728+ arglist = [
729+ '--all-projects' ,
730+ ]
731+ verifylist = [
732+ ('all_projects' , True ),
733+ ]
734+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
735+
736+ columns , data = self .cmd .take_action (parsed_args )
737+ self .compute .security_groups .list .assert_called_once_with (
738+ search_opts = {'all_tenants' : True }
739+ )
740+ self .assertEqual (self .expected_columns_no_group , columns )
741+ self .assertEqual (self .expected_data_no_group , list (data ))
742+
743+ def test_list_with_ignored_options (self ):
744+ arglist = [
745+ '--long' ,
746+ ]
747+ verifylist = [
748+ ('long' , False ),
749+ ]
750+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
751+
752+ columns , data = self .cmd .take_action (parsed_args )
753+ self .compute .security_groups .list .assert_called_once_with (
754+ search_opts = {'all_tenants' : False }
755+ )
756+ self .assertEqual (self .expected_columns_no_group , columns )
757+ self .assertEqual (self .expected_data_no_group , list (data ))
758+
692759
693760class TestShowSecurityGroupRuleNetwork (TestSecurityGroupRuleNetwork ):
694761
0 commit comments