1212# under the License.
1313#
1414
15+ import argparse
1516import mock
1617from mock import call
1718
@@ -260,16 +261,33 @@ def test_snapshot_list_without_options(self):
260261 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
261262
262263 columns , data = self .cmd .take_action (parsed_args )
264+
265+ self .snapshots_mock .list .assert_called_once_with (
266+ limit = None , marker = None , search_opts = {'all_tenants' : False })
263267 self .assertEqual (self .columns , columns )
264268 self .assertEqual (self .data , list (data ))
265269
266270 def test_snapshot_list_with_options (self ):
267- arglist = ["--long" ]
268- verifylist = [("long" , True ), ('all_projects' , False )]
271+ arglist = [
272+ "--long" ,
273+ "--limit" , "2" ,
274+ "--marker" , self .snapshots [0 ].id ,
275+ ]
276+ verifylist = [
277+ ("long" , True ),
278+ ("limit" , 2 ),
279+ ("marker" , self .snapshots [0 ].id ),
280+ ('all_projects' , False ),
281+ ]
269282 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
270283
271284 columns , data = self .cmd .take_action (parsed_args )
272285
286+ self .snapshots_mock .list .assert_called_once_with (
287+ limit = 2 ,
288+ marker = self .snapshots [0 ].id ,
289+ search_opts = {'all_tenants' : False }
290+ )
273291 self .assertEqual (self .columns_long , columns )
274292 self .assertEqual (self .data_long , list (data ))
275293
@@ -285,9 +303,21 @@ def test_snapshot_list_all_projects(self):
285303
286304 columns , data = self .cmd .take_action (parsed_args )
287305
306+ self .snapshots_mock .list .assert_called_once_with (
307+ limit = None , marker = None , search_opts = {'all_tenants' : True })
288308 self .assertEqual (self .columns , columns )
289309 self .assertEqual (self .data , list (data ))
290310
311+ def test_snapshot_list_negative_limit (self ):
312+ arglist = [
313+ "--limit" , "-2" ,
314+ ]
315+ verifylist = [
316+ ("limit" , - 2 ),
317+ ]
318+ self .assertRaises (argparse .ArgumentTypeError , self .check_parser ,
319+ self .cmd , arglist , verifylist )
320+
291321
292322class TestSnapshotSet (TestSnapshot ):
293323
0 commit comments