#NEWLINE# def test_find_actions( self ) : #NEWLINE# #INDENT# sh = shell . SenlinShell ( ) #NEWLINE# sh . subcommands = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# subparsers = mock . Mock ( ) #NEWLINE# x_subparser1 = mock . Mock ( ) #NEWLINE# x_subparser2 = mock . Mock ( ) #NEWLINE# x_add_parser = mock . MagicMock ( side_effect = [ x_subparser1 , x_subparser2 ] ) #NEWLINE# subparsers . add_parser = x_add_parser #NEWLINE# sh . _find_actions ( subparsers , fakes ) #NEWLINE# self . assertEqual ( { #NEWLINE# #INDENT# 'command-bar' : x_subparser1 , #NEWLINE# 'command-foo' : x_subparser2 , #NEWLINE# #UNINDENT# } , subparsers . subcommands ) #NEWLINE# add_calls = [ mock . call ( 'command-bar' , help = 'This is the command doc.' , description = 'This is the command doc.' , add_help = False , formatter_class = shell . HelpFormatter ) , mock . call ( 'command-foo' , help = 'Pydoc for command foo.' , description = 'Pydoc for command foo.' , add_help = False , formatter_class = shell . HelpFormatter ) ] #NEWLINE# x_add_parser . assert_has_calls ( add_calls ) #NEWLINE# calls_1 = [ mock . call ( '-h' , '--help' , action = 'help' , help = argparse . SUPPRESS ) , mock . call ( '-F' , '--flag' , metavar = '<FLAG>' , help = 'Flag desc.' ) , mock . call ( 'arg1' , metavar = '<ARG1>' , help = 'Arg1 desc' ) ] #NEWLINE# x_subparser1 . add_argument . assert_has_calls ( calls_1 ) #NEWLINE# x_subparser1 . set_defaults . assert_called_once_with ( func = fakes . do_command_bar ) #NEWLINE# calls_2 = [ mock . call ( '-h' , '--help' , action = 'help' , help = argparse . SUPPRESS ) ] #NEWLINE# x_subparser2 . add_argument . assert_has_calls ( calls_2 ) #NEWLINE# x_subparser2 . set_defaults . assert_called_once_with ( func = fakes . do_command_foo )