示例#1
0
 def testGetShellCommands(self):
     command, _ = common.get_shell_commands("yum install nfs-utils")
     self.assertEqual(type(command), list)
     self.assertEqual(len(command), 1)
     self.assertEqual(command[0].options, self.command1.options)
     # test on branching command
     branching_script = "if [ -z $var ]; then yum install nfs-utils; fi"
     branch_command, report = common.get_shell_commands(branching_script)
     self.assertEqual(type(branch_command), list)
     # we will ignore branching command, so len should be 0
     self.assertEqual(len(branch_command), 0)
     # and the report should not be None
     self.assertTrue(report)
示例#2
0
def filter_install_commands(shell_command_line):
    '''Given a shell command line:
        1. Create a list of Command objects
        2. For each command, check against the command library for installed
        commands
        3. Return installed command objects, and messages for ignored commands
        and unrecognized commands'''
    report = ''
    command_list, branch_report = common.get_shell_commands(shell_command_line)
    for command in command_list:
        command_lib.set_command_attrs(command)
    ignore_msgs, filter1 = remove_ignored_commands(command_list)
    unrec_msgs, filter2 = remove_unrecognized_commands(filter1)
    if ignore_msgs:
        report = report + formats.ignored + ignore_msgs
    if unrec_msgs:
        report += formats.unrecognized + unrec_msgs
    if branch_report:
        report = report + branch_report
    return consolidate_commands(filter2), report
 def testGetShellCommands(self):
     command = common.get_shell_commands("yum install nfs-utils")
     self.assertEqual(type(command), list)
     self.assertEqual(len(command), 1)
     self.assertEqual(command[0].options, self.command1.options)