@@ -327,14 +327,27 @@ class TestListNetworkRABC(TestNetworkRBAC):
327327 'Object Type' ,
328328 'Object ID' ,
329329 )
330-
330+ columns_long = (
331+ 'ID' ,
332+ 'Object Type' ,
333+ 'Object ID' ,
334+ 'Action' ,
335+ )
331336 data = []
332337 for r in rbac_policies :
333338 data .append ((
334339 r .id ,
335340 r .object_type ,
336341 r .object_id ,
337342 ))
343+ data_long = []
344+ for r in rbac_policies :
345+ data_long .append ((
346+ r .id ,
347+ r .object_type ,
348+ r .object_id ,
349+ r .action ,
350+ ))
338351
339352 def setUp (self ):
340353 super (TestListNetworkRABC , self ).setUp ()
@@ -356,6 +369,55 @@ def test_network_rbac_list(self):
356369 self .assertEqual (self .columns , columns )
357370 self .assertEqual (self .data , list (data ))
358371
372+ def test_network_rbac_list_type_opt (self ):
373+ arglist = [
374+ '--type' , self .rbac_policies [0 ].object_type , ]
375+ verifylist = [
376+ ('type' , self .rbac_policies [0 ].object_type )]
377+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
378+
379+ # DisplayCommandBase.take_action() returns two tuples
380+ columns , data = self .cmd .take_action (parsed_args )
381+
382+ self .network .rbac_policies .assert_called_with (** {
383+ 'object_type' : self .rbac_policies [0 ].object_type
384+ })
385+ self .assertEqual (self .columns , columns )
386+ self .assertEqual (self .data , list (data ))
387+
388+ def test_network_rbac_list_action_opt (self ):
389+ arglist = [
390+ '--action' , self .rbac_policies [0 ].action , ]
391+ verifylist = [
392+ ('action' , self .rbac_policies [0 ].action )]
393+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
394+
395+ # DisplayCommandBase.take_action() returns two tuples
396+ columns , data = self .cmd .take_action (parsed_args )
397+
398+ self .network .rbac_policies .assert_called_with (** {
399+ 'action' : self .rbac_policies [0 ].action
400+ })
401+ self .assertEqual (self .columns , columns )
402+ self .assertEqual (self .data , list (data ))
403+
404+ def test_network_rbac_list_with_long (self ):
405+ arglist = [
406+ '--long' ,
407+ ]
408+
409+ verifylist = [
410+ ('long' , True ),
411+ ]
412+
413+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
414+
415+ columns , data = self .cmd .take_action (parsed_args )
416+
417+ self .network .rbac_policies .assert_called_with ()
418+ self .assertEqual (self .columns_long , columns )
419+ self .assertEqual (self .data_long , list (data ))
420+
359421
360422class TestSetNetworkRBAC (TestNetworkRBAC ):
361423
0 commit comments