Example #1
0
def test_run_command_grab_output_as_string_count_lines(
    reset_results_dictionary, tmpdir
):
    """Checks that invocation of command produces correct captured output for line count"""
    tmpdir.mkdir("Hello1")
    tmpdir.mkdir("Hello2")
    tmpdir.mkdir("Hello3")
    assert len(tmpdir.listdir()) == 3
    directory = tmpdir.dirname + "/" + tmpdir.basename + "/"
    met_or_exceeded_count = invoke.invoke_all_command_count_checks("ls " + directory, 1)
    assert met_or_exceeded_count is True
    met_or_exceeded_count = invoke.invoke_all_command_count_checks("ls " + directory, 4)
    assert met_or_exceeded_count is False
    details = report.get_result()
    assert details is not None
Example #2
0
def act(main_parsed_arguments, check_remaining_arguments):
    """Perform the action for this check."""
    # extract the two arguments for this check:
    # --> command is required to specify the command to perform
    # --> count is required to specify the expected number of lines in the output
    # --> exact is optional, but will either be True or False and False by default
    check_parsed_arguments = parse(check_remaining_arguments)
    # Directly run the check since at least one of the argument's for it is mandatory.
    # This means that the use of check_CountCommandOutput would have already failed by this
    # point since argparse will exit the program if a command-line argument is not provided.
    command = check_parsed_arguments.command
    count = check_parsed_arguments.count
    exact = check_parsed_arguments.exact
    return [invoke.invoke_all_command_count_checks(command, count, exact)]