Esempio n. 1
0
def test_output_text_diagnostic(reset_results_dictionary):
    """Set the report and check the textual output."""
    report.set_result("Command executes", False, "Missing trailing slash")
    output = report.output(report.get_result(), report.TEXT)
    assert "Command executes" in output
    assert "Missing trailing slash" in output
    assert "\n" in output
Esempio n. 2
0
def test_output_json_complete(reset_results_dictionary):
    """Add multiple row to the report and check final output as JSON-based text"""
    report.add_result("Command executes", True, "")
    report.add_result("Check for 3 paragraphs", False, "Only found 2 paragraphs")
    report.add_result("Check for 10 comments", False, "Only found 2 comments")
    output_list = report.output_list(report.get_details(), report.JSON)
    assert len(output_list) == 3
    output = " ".join(output_list)
    produced_output = report.output(output_list)
    assert output == produced_output
Esempio n. 3
0
def test_output_json(reset_results_dictionary):
    """Set the report and check output as JSON-based text."""
    report.set_result("Command executes", True, "")
    output = report.output(report.get_result(), report.JSON)
    assert output is not None
    assert "\n" not in output
    assert "Command executes" in output
    assert "true" in output
    assert f'"{constants.results.Check}":' in output
    assert f'"{constants.results.Outcome}":' in output
    assert f'"{constants.results.Diagnostic}":' in output
Esempio n. 4
0
def test_output_json(reset_results_dictionary):
    """Set the report and check output as JSON-based text"""
    report.set_result("Command executes", True, "")
    output = report.output(report.get_result(), report.JSON)
    assert output is not None
    assert "\n" not in output
    assert "Command executes" in output
    assert "true" in output
    assert f'"{report.CHECK}":' in output
    assert f'"{report.OUTCOME}":' in output
    assert f'"{report.DIAGNOSTIC}":' in output
Esempio n. 5
0
def check(system_arguments):
    """Orchestrate a full check of the specified deliverables."""
    # *Section: Initialize
    # step_results = []
    check_results = []
    # **Step: Parse and then verify the arguments, extract remaining arguments
    parsed_arguments, remaining_arguments = parse_arguments(system_arguments)
    verification_status = verify_arguments(parsed_arguments)
    # **Step: Get the source of all the checkers available from either:
    # --> the internal directory of checkers (e.g., "./gator/checks")
    # --> the directory specified on the command-line
    external_checker_directory = checkers.get_checker_dir(parsed_arguments)
    checker_source = checkers.get_source([external_checker_directory])
    # **Step: Get and perform the preliminary actions before running a checker
    # if the arguments did not parse or verify correctly, then:
    # --> argparse will cause the program to crash with an error OR
    # --> one of the actions will be to display the help message and exit
    actions = get_actions(parsed_arguments, verification_status)
    perform_actions(actions)
    # *Section: Perform the check
    # **Step: Get and transform the name of the chosen checker and
    # then prepare for running it by ensuring that it is:
    # --> available for use (i.e., pluginbase found and loaded it)
    check_name = checkers.get_chosen_check(parsed_arguments)
    check_file = checkers.transform_check(check_name)
    check_exists = checkers.verify_check_existence(check_file, checker_source)
    # **Step: Load the check and verify that it is valid:
    check_verified = False
    check = None
    if check_exists:
        check = checker_source.load_plugin(check_file)
        check_verified = checkers.verify_check_functions(check)
    # produce error message and exit because the check is not valid
    if not check_exists or not check_verified:
        # do not potentially produce the welcome message again
        parsed_arguments.nowelcome = True
        actions = get_actions(parsed_arguments, check_verified)
        perform_actions(actions)
    # **Step: Perform the check since it exists and it is verified
    check_result = check.act(parsed_arguments, remaining_arguments)
    check_results.extend(check_result)
    # *Section: Output the report
    # **Step: get the report's details
    result = report.get_result()
    # **Step: Override the result's description if a user-provided description exists
    result = description.transform_result_dictionary(parsed_arguments, result)
    # **Step: produce the output
    produced_output = report.output(report.get_result(), OUTPUT_TYPE)
    # **Step: display the output
    display.message(produced_output)
    # Section: Return control back to __main__ in gatorgrader
    # Only step: determine the correct exit code for the checks
    correct_exit_code = leave.get_code(check_results)
    return correct_exit_code
Esempio n. 6
0
def check(system_arguments):
    """Orchestrate a full check of the specified deliverables"""
    # Section: Initialize
    # Only step: check the arguments
    step_results = []
    check_results = []
    gg_arguments, arguments_actions = check_arguments(system_arguments)
    step_results = perform(arguments_actions)
    check_results.extend(step_results)
    # Section: Perform one of these checks
    checks = [
        "check_commits",
        "check_exists",
        "check_single",
        "check_multiple",
        "check_paragraphs",
        "check_words",
        "check_markdown_file",
        "check_fragment_file",
        "check_fragment_command",
        "check_count_file",
        "check_count_command",
        "check_executes_command",
        "check_regex_file",
        "check_regex_command",
    ]
    # iterate through all of the possible checks
    for a_check in checks:
        # reflectively create the checking function
        check_to_invoke = getattr(ORCHESTRATE, a_check)
        # call the checking function and get actions
        actions = check_to_invoke(gg_arguments)
        # perform the actions and get results
        step_results = perform(actions)
        # store the results from these actions
        check_results.extend(step_results)
    # Section: Output the report
    # Only step: get the report's details, produce the output, and display it
    produced_output = report.output(report.get_result(), OUTPUT_TYPE)
    display.message(produced_output)
    # Section: Return control back to __main__ in gatorgrader
    # Only step: determine the correct exit code for the checks
    correct_exit_code = leave.get_code(check_results)
    return correct_exit_code
Esempio n. 7
0
def test_output_text(reset_results_dictionary):
    """Set the report and check the textual output."""
    report.set_result("Command executes", True, "")
    output = report.output(report.get_result(), report.TEXT)
    assert "Command executes" in output
    assert "\n" not in output