@@ -55,3 +55,72 @@ def test_delete(self):
5555
5656 self .network .delete_subnet_pool .assert_called_with (self ._subnet_pool )
5757 self .assertIsNone (result )
58+
59+
60+ class TestListSubnetPool (TestSubnetPool ):
61+ # The subnet pools going to be listed up.
62+ _subnet_pools = network_fakes .FakeSubnetPool .create_subnet_pools (count = 3 )
63+
64+ columns = (
65+ 'ID' ,
66+ 'Name' ,
67+ 'Prefixes' ,
68+ )
69+ columns_long = columns + (
70+ 'Default Prefix Length' ,
71+ 'Address Scope' ,
72+ )
73+
74+ data = []
75+ for pool in _subnet_pools :
76+ data .append ((
77+ pool .id ,
78+ pool .name ,
79+ pool .prefixes ,
80+ ))
81+
82+ data_long = []
83+ for pool in _subnet_pools :
84+ data_long .append ((
85+ pool .id ,
86+ pool .name ,
87+ pool .prefixes ,
88+ pool .default_prefixlen ,
89+ pool .address_scope_id ,
90+ ))
91+
92+ def setUp (self ):
93+ super (TestListSubnetPool , self ).setUp ()
94+
95+ # Get the command object to test
96+ self .cmd = subnet_pool .ListSubnetPool (self .app , self .namespace )
97+
98+ self .network .subnet_pools = mock .Mock (return_value = self ._subnet_pools )
99+
100+ def test_subnet_pool_list_no_option (self ):
101+ arglist = []
102+ verifylist = [
103+ ('long' , False ),
104+ ]
105+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
106+
107+ columns , data = self .cmd .take_action (parsed_args )
108+
109+ self .network .subnet_pools .assert_called_with ()
110+ self .assertEqual (self .columns , columns )
111+ self .assertEqual (self .data , list (data ))
112+
113+ def test_subnet_pool_list_long (self ):
114+ arglist = [
115+ '--long' ,
116+ ]
117+ verifylist = [
118+ ('long' , True ),
119+ ]
120+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
121+
122+ columns , data = self .cmd .take_action (parsed_args )
123+
124+ self .network .subnet_pools .assert_called_with ()
125+ self .assertEqual (self .columns_long , columns )
126+ self .assertEqual (self .data_long , list (data ))
0 commit comments