Esempio n. 1
0
def test_file_exists_in_directory_check_lines_exact(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, "", True)
    invoke.invoke_all_count_checks(100, reflection_file, directory, "", True)
    details = report.get_result()
    assert details is not None
Esempio n. 2
0
def test_content_string_check_fragments_with_threshold(reset_results_dictionary):
    """Checks that the checking of words works correctly"""
    value = "hello world 44 fine\n\nhi there nice again\n\nff! Is now $@name again\n\n"
    invoke.invoke_all_count_checks(1, contents=value)
    invoke.invoke_all_count_checks(2, contents=value)
    invoke.invoke_all_count_checks(7, contents=value)
    details = report.get_result()
    assert details is not None
Esempio n. 3
0
def act(main_parsed_arguments, check_remaining_arguments):
    """Perform the action for this check."""
    # extract the two arguments for this check:
    # --> file is the name of the file for which the search is conducted
    # --> directory is the name of the directory that should contain the specified file
    # --> count is required to specify the expected number of lines in the file
    # --> 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_CountFileLines would have already failed by this
    # point since argparse will exit the program if a command-line argument is not provided.
    count = check_parsed_arguments.count
    file = check_parsed_arguments.file
    directory = check_parsed_arguments.directory
    exact = check_parsed_arguments.exact
    return [
        invoke.invoke_all_count_checks(count, file, directory,
                                       constants.markers.Nothing, exact)
    ]