@@ -173,6 +173,30 @@ def test_hypervisor_list_matching_option_not_found(self):
173173 self .cmd .take_action ,
174174 parsed_args )
175175
176+ def test_hypervisor_list_with_matching_and_pagination_options (self ):
177+ self .app .client_manager .compute .api_version = \
178+ api_versions .APIVersion ('2.32' )
179+
180+ arglist = [
181+ '--matching' , self .hypervisors [0 ].hypervisor_hostname ,
182+ '--limit' , '1' ,
183+ '--marker' , self .hypervisors [0 ].hypervisor_hostname ,
184+ ]
185+ verifylist = [
186+ ('matching' , self .hypervisors [0 ].hypervisor_hostname ),
187+ ('limit' , 1 ),
188+ ('marker' , self .hypervisors [0 ].hypervisor_hostname ),
189+ ]
190+
191+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
192+ ex = self .assertRaises (
193+ exceptions .CommandError ,
194+ self .cmd .take_action ,
195+ parsed_args )
196+
197+ self .assertIn (
198+ '--matching is not compatible with --marker or --limit' , str (ex ))
199+
176200 def test_hypervisor_list_long_option (self ):
177201 arglist = [
178202 '--long' ,
@@ -191,6 +215,78 @@ def test_hypervisor_list_long_option(self):
191215 self .assertEqual (self .columns_long , columns )
192216 self .assertEqual (self .data_long , tuple (data ))
193217
218+ def test_hypervisor_list_with_limit (self ):
219+ self .app .client_manager .compute .api_version = \
220+ api_versions .APIVersion ('2.33' )
221+
222+ arglist = [
223+ '--limit' , '1' ,
224+ ]
225+ verifylist = [
226+ ('limit' , 1 ),
227+ ]
228+
229+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
230+ self .cmd .take_action (parsed_args )
231+
232+ self .hypervisors_mock .list .assert_called_with (limit = 1 )
233+
234+ def test_hypervisor_list_with_limit_pre_v233 (self ):
235+ self .app .client_manager .compute .api_version = \
236+ api_versions .APIVersion ('2.32' )
237+
238+ arglist = [
239+ '--limit' , '1' ,
240+ ]
241+ verifylist = [
242+ ('limit' , 1 ),
243+ ]
244+
245+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
246+ ex = self .assertRaises (
247+ exceptions .CommandError ,
248+ self .cmd .take_action ,
249+ parsed_args )
250+
251+ self .assertIn (
252+ '--os-compute-api-version 2.33 or greater is required' , str (ex ))
253+
254+ def test_hypervisor_list_with_marker (self ):
255+ self .app .client_manager .compute .api_version = \
256+ api_versions .APIVersion ('2.33' )
257+
258+ arglist = [
259+ '--marker' , 'test_hyp' ,
260+ ]
261+ verifylist = [
262+ ('marker' , 'test_hyp' ),
263+ ]
264+
265+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
266+ self .cmd .take_action (parsed_args )
267+
268+ self .hypervisors_mock .list .assert_called_with (marker = 'test_hyp' )
269+
270+ def test_hypervisor_list_with_marker_pre_v233 (self ):
271+ self .app .client_manager .compute .api_version = \
272+ api_versions .APIVersion ('2.32' )
273+
274+ arglist = [
275+ '--marker' , 'test_hyp' ,
276+ ]
277+ verifylist = [
278+ ('marker' , 'test_hyp' ),
279+ ]
280+
281+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
282+ ex = self .assertRaises (
283+ exceptions .CommandError ,
284+ self .cmd .take_action ,
285+ parsed_args )
286+
287+ self .assertIn (
288+ '--os-compute-api-version 2.33 or greater is required' , str (ex ))
289+
194290
195291class TestHypervisorShow (TestHypervisor ):
196292
0 commit comments