def test_file_exists_in_directory_check_words_wildcards( reset_results_dictionary, tmpdir): """Check that the checking of words works correctly.""" reflection_file = tmpdir.mkdir("sub").join("reflection.md") reflection_file.write( "hello world 44 fine\n\nhi there nice again\n\nff! Is now $@name again\n\n" ) assert ( reflection_file.read() == "hello world 44 fine\n\nhi there nice again\n\nff! Is now $@name again\n\n" ) assert len(tmpdir.listdir()) == 1 directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "sub" reflection_file = "*.md" invoke.invoke_all_minimum_word_count_checks( reflection_file, directory, 4, fragments.count_minimum_words, constants.words.Minimum, ) details = report.get_result() assert details is not None report.reset() invoke.invoke_all_minimum_word_count_checks( reflection_file, directory, 200, fragments.count_minimum_words, constants.words.Minimum, ) details = report.get_result() assert details is not None
def test_file_exists_in_directory_check_paragraphs(reset_results_dictionary, tmpdir): """Checks that the checking of paragraphs works correctly""" reflection_file = tmpdir.mkdir("sub").join("reflection.md") reflection_file.write("hello world 44\n\nhi\n\nff!$@name\n\n^^44") assert reflection_file.read() == "hello world 44\n\nhi\n\nff!$@name\n\n^^44" assert len(tmpdir.listdir()) == 1 directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "sub" reflection_file = "reflection.md" invoke.invoke_all_paragraph_checks(reflection_file, directory, 4) details = report.get_result() assert details is not None report.reset() invoke.invoke_all_paragraph_checks(reflection_file, directory, 200) details = report.get_result() assert details is not None
def test_comment_counts_check_multiple_java(reset_results_dictionary, tmpdir): """Checks that invocation of comment counting check works correctly""" hello_file = tmpdir.mkdir("subdirectory").join("Hello.java") hello_file.write("/* hello world */") assert hello_file.read() == "/* hello world */" assert len(tmpdir.listdir()) == 1 directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "subdirectory" hello_file = "Hello.java" invoke.invoke_file_in_directory_check(hello_file, directory) details = report.get_result() assert details is not None report.reset() invoke.invoke_all_comment_checks(hello_file, directory, 1, "multiple-line", "Java") details = report.get_result() assert details is not None
def test_comment_counts_check_multiple_python_not_enough( reset_results_dictionary, tmpdir): """Check that invocation of comment counting check works correctly.""" hello_file = tmpdir.mkdir("subdirectory").join("Hello.py") hello_file.write('""" hello world """') assert hello_file.read() == '""" hello world """' assert len(tmpdir.listdir()) == 1 # directory = tmpdir.dirname + '"""' + tmpdir.basename + '"""' + "subdirectory" directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "subdirectory" hello_file = "Hello.py" invoke.invoke_file_in_directory_check(hello_file, directory) details = report.get_result() assert details is not None report.reset() invoke.invoke_all_comment_checks(hello_file, directory, 100, "multiple-line", "Python") details = report.get_result() assert details is not None
def test_run_command_grab_output_as_string(reset_results_dictionary, tmpdir): """Check that invocation of command produces correct captured output.""" 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_fragment_checks( "ls " + directory, "Hello1", 1) assert met_or_exceeded_count is True details = report.get_result() assert details is not None report.reset() met_or_exceeded_count = invoke.invoke_all_command_fragment_checks( "ls " + directory, "HelloNotThere", 1) assert met_or_exceeded_count is False met_or_exceeded_count = invoke.invoke_all_command_fragment_checks( "ls " + directory, "HelloNotThere", 0) assert met_or_exceeded_count is True
def test_comment_counts_check_multiple_java_invalid_check( reset_results_dictionary, tmpdir): """Check that invocation of comment counting check works correctly.""" hello_file = tmpdir.mkdir("subdirectory").join("Hello.java") hello_file.write("/* hello world */") assert hello_file.read() == "/* hello world */" assert len(tmpdir.listdir()) == 1 directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "subdirectory" hello_file = "Hello.java" invoke.invoke_file_in_directory_check(hello_file, directory) details = report.get_result() assert details is not None report.reset() # this check cannot pass because of the fact that it asks # for "standard-line" comments, which are not supported by this function invoke.invoke_all_comment_checks(hello_file, directory, 1, "standard-line", "Java") details = report.get_result() assert details is not None
def test_file_exists_in_directory_check_lines(reset_results_dictionary, tmpdir): """Checks that the checking of lines in a file works correctly""" reflection_file = tmpdir.mkdir("sub").join("reflection.md") reflection_file.write( "hello world 44 fine\n\nhi there nice again\n\nff! Is now $@name again\n\n" ) assert ( reflection_file.read() == "hello world 44 fine\n\nhi there nice again\n\nff! Is now $@name again\n\n" ) assert len(tmpdir.listdir()) == 1 directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "sub" reflection_file = "reflection.md" invoke.invoke_all_count_checks(1, reflection_file, directory, "") details = report.get_result() assert details is not None report.reset() invoke.invoke_all_count_checks(100, reflection_file, directory, "") details = report.get_result() assert details is not None
def test_file_exists_in_directory_check_total_words_exact( reset_results_dictionary, tmpdir): """Check that the checking of total words works exactly correctly.""" reflection_file = tmpdir.mkdir("sub").join("reflection.md") reflection_file.write( "hello world 44 fine\n\nhi there nice again\n\nff! Is now $@name again\n\n" ) assert ( reflection_file.read() == "hello world 44 fine\n\nhi there nice again\n\nff! Is now $@name again\n\n" ) assert len(tmpdir.listdir()) == 1 directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "sub" reflection_file = "reflection.md" # invoke.invoke_all_total_word_count_checks( # reflection_file, directory, 12, exact=True # ) invoke.invoke_all_total_word_count_checks( reflection_file, directory, 12, fragments.count_total_words, constants.words.Total, exact=True, ) details = report.get_result() assert details is not None report.reset() # invoke.invoke_all_total_word_count_checks( # reflection_file, directory, 100, exact=True # ) invoke.invoke_all_total_word_count_checks( reflection_file, directory, 100, fragments.count_total_words, constants.words.Total, exact=True, ) details = report.get_result() assert details is not None
def reset_results_dictionary(): """Reset the state of the results dictionary""" report.reset()