@@ -71,3 +71,98 @@ def test_capability_show(self):
7171 self .capability_mock .get .assert_called_with (
7272 'fake' ,
7373 )
74+
75+
76+ class TestListVolumePool (volume_fakes .TestVolume ):
77+ """Tests for volume backend pool listing."""
78+
79+ # The pool to be listed
80+ pools = volume_fakes .FakePool .create_one_pool ()
81+
82+ def setUp (self ):
83+ super (TestListVolumePool , self ).setUp ()
84+
85+ self .pool_mock = self .app .client_manager .volume .pools
86+ self .pool_mock .list .return_value = [self .pools ]
87+
88+ # Get the command object to test
89+ self .cmd = volume_backend .ListPool (self .app , None )
90+
91+ def test_pool_list (self ):
92+ arglist = []
93+ verifylist = []
94+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
95+
96+ # In base command class Lister in cliff, abstract method take_action()
97+ # returns a tuple containing the column names and an iterable
98+ # containing the data to be listed.
99+ columns , data = self .cmd .take_action (parsed_args )
100+
101+ expected_columns = [
102+ 'Name' ,
103+ ]
104+
105+ # confirming if all expected columns are present in the result.
106+ self .assertEqual (expected_columns , columns )
107+
108+ datalist = ((
109+ self .pools .name ,
110+ ), )
111+
112+ # confirming if all expected values are present in the result.
113+ self .assertEqual (datalist , tuple (data ))
114+
115+ # checking if proper call was made to list pools
116+ self .pool_mock .list .assert_called_with (
117+ detailed = False ,
118+ )
119+
120+ # checking if long columns are present in output
121+ self .assertNotIn ("total_volumes" , columns )
122+ self .assertNotIn ("storage_protocol" , columns )
123+
124+ def test_service_list_with_long_option (self ):
125+ arglist = [
126+ '--long'
127+ ]
128+ verifylist = [
129+ ('long' , True )
130+ ]
131+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
132+
133+ # In base command class Lister in cliff, abstract method take_action()
134+ # returns a tuple containing the column names and an iterable
135+ # containing the data to be listed.
136+ columns , data = self .cmd .take_action (parsed_args )
137+
138+ expected_columns = [
139+ 'Name' ,
140+ 'Protocol' ,
141+ 'Thick' ,
142+ 'Thin' ,
143+ 'Volumes' ,
144+ 'Capacity' ,
145+ 'Allocated' ,
146+ 'Max Over Ratio' ,
147+ ]
148+
149+ # confirming if all expected columns are present in the result.
150+ self .assertEqual (expected_columns , columns )
151+
152+ datalist = ((
153+ self .pools .name ,
154+ self .pools .storage_protocol ,
155+ self .pools .thick_provisioning_support ,
156+ self .pools .thin_provisioning_support ,
157+ self .pools .total_volumes ,
158+ self .pools .total_capacity_gb ,
159+ self .pools .allocated_capacity_gb ,
160+ self .pools .max_over_subscription_ratio ,
161+ ), )
162+
163+ # confirming if all expected values are present in the result.
164+ self .assertEqual (datalist , tuple (data ))
165+
166+ self .pool_mock .list .assert_called_with (
167+ detailed = True ,
168+ )
0 commit comments