def test_perform_actions_display_welcome_and_exit_check(capsys): """Check the argument verification, messages, and exit""" chosen_arguments = ["--directory", "D", "--file", "f"] with pytest.raises(SystemExit) as pytest_wrapped_e: orchestrate.check(chosen_arguments) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 2 captured = capsys.readouterr() counted_newlines = captured.out.count("\n") assert "GatorGrader" in captured.out assert counted_newlines == 6
def test_perform_actions_display_welcome_and_ready_check_commit( capsys, reset_results_dictionary): """Check the argument verification, messages, and continue""" chosen_arguments = ["--commits", "33"] exit_code = orchestrate.check(chosen_arguments) captured = capsys.readouterr() counted_newlines = captured.out.count("\n") assert "GatorGrader" in captured.out assert counted_newlines == 6 assert exit_code == 0
def test_check_produces_correct_output_for_incorrect_check_specification( commandline_arguments, capsys): """Ensure that using the check produces output.""" with pytest.raises(SystemExit): _ = orchestrate.check(commandline_arguments) captured = capsys.readouterr() counted_newlines = captured.out.count("\n") assert captured.err == "" assert captured.out != "" assert "Incorrect command-line arguments." in captured.out assert counted_newlines > 5
def test_perform_actions_display_welcome_and_ready_check_count_command_json( capsys, reset_results_dictionary): """Check the argument verification, messages, and continue for JSON output""" chosen_arguments = [ "--nowelcome", "--command", "ls", "--count", "2", "--json" ] exit_code = orchestrate.check(chosen_arguments) captured = capsys.readouterr() counted_newlines = captured.out.count("\n") assert "GatorGrader" not in captured.out assert counted_newlines == 2 assert exit_code == 0
def test_check_produces_correct_output(commandline_arguments, expected_result, capsys): """Ensure that using the check produces output.""" testargs = [os.getcwd()] with patch.object(sys, "argv", testargs): check_exit_code = orchestrate.check(commandline_arguments) captured = capsys.readouterr() counted_newlines = captured.out.count("\n") assert check_exit_code == expected_result assert captured.err == "" assert captured.out != "" assert counted_newlines > 5 assert "has exactly" in captured.out or "has at least" in captured.out
def test_perform_actions_display_welcome_and_ready_check_regex_command( capsys, reset_results_dictionary): """Check the argument verification, messages, and continue for regex output""" chosen_arguments = [ "--command", "ls", "--regex", r"G\S{4}G\S{4}r", "--count", "1" ] exit_code = orchestrate.check(chosen_arguments) captured = capsys.readouterr() counted_newlines = captured.out.count("\n") assert "GatorGrader" in captured.out assert "regular expression" in captured.out assert "Found 0 matches" in captured.out assert counted_newlines == 7 assert exit_code == 1
def test_perform_actions_display_welcome_and_ready_check_markdown_tag_file( capsys, reset_results_dictionary): """Check the argument verification, messages, and continue""" chosen_arguments = [ "--directory", "D", "--file", "f", "--markdown", "code", "--count", "2", ] exit_code = orchestrate.check(chosen_arguments) captured = capsys.readouterr() counted_newlines = captured.out.count("\n") assert "GatorGrader" in captured.out assert counted_newlines == 7 assert exit_code == 1
def test_perform_actions_display_welcome_and_ready_check_regex_file( capsys, reset_results_dictionary): """Check the argument verification, messages, and continue""" chosen_arguments = [ "--directory", "D", "--file", "f", "--regex", r"\\begin(.*?)\\end", "--count", "1", ] exit_code = orchestrate.check(chosen_arguments) captured = capsys.readouterr() counted_newlines = captured.out.count("\n") assert "GatorGrader" in captured.out assert "regular expression" in captured.out assert "Found 0 matches" in captured.out assert counted_newlines == 7 assert exit_code == 1
"""GatorGrader checks the files of programmers and technical writers.""" import sys from gator import orchestrate if __name__ == "__main__": # orchestrate check(s) of the specified deliverable(s) exit_code = orchestrate.check(sys.argv[1:]) # exit the program with the correct code # error code: one aspect of the checks failed # normal code: all aspects of the checks passed sys.exit(exit_code)