示例#1
0
def test_content_string_check_fragments_exact(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_fragment_checks("hello", 1, invoke.NOTHING,
                                      invoke.NOTHING, value, True)
    details = report.get_details()
    assert details is not None
示例#2
0
def test_file_exists_in_directory_check_fragments(reset_results_dictionary,
                                                  tmpdir):
    """Check that the checking of fragments 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_fragment_checks("hello", 1, reflection_file, directory,
                                      "")
    details = report.get_result()
    assert details is not None
    report.reset()
    invoke.invoke_all_fragment_checks("@name", 1, reflection_file, directory,
                                      "")
    details = report.get_result()
    assert details is not None
    report.reset()
    invoke.invoke_all_fragment_checks("again", 2, reflection_file, directory,
                                      "")
    details = report.get_result()
    assert details is not None
    report.reset()
    invoke.invoke_all_fragment_checks("planet", 2, reflection_file, directory,
                                      "")
    details = report.get_result()
    assert details is not None
示例#3
0
def test_content_string_check_fragments(reset_results_dictionary):
    """Check 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_fragment_checks("hello", 1, contents=value)
    invoke.invoke_all_fragment_checks("@name", 1, contents=value)
    invoke.invoke_all_fragment_checks("@name", 2, contents=value)
    invoke.invoke_all_fragment_checks("planet", 2, contents=value)
    details = report.get_result()
    assert details is not None
示例#4
0
def act(main_parsed_arguments, check_remaining_arguments):
    """Perform the action for this check."""
    # extract the two arguments for this check:
    # --> fragment is the content that should appear in the file
    # --> 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 number of fragments to appear 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_MatchFileFragment would have already failed by this
    # point since argparse will exit the program if a command-line argument is not provided.
    fragment = check_parsed_arguments.fragment
    count = check_parsed_arguments.count
    file = check_parsed_arguments.file
    directory = check_parsed_arguments.directory
    exact = check_parsed_arguments.exact
    return [
        invoke.invoke_all_fragment_checks(fragment, count, file, directory,
                                          constants.markers.Nothing, exact)
    ]