Exemplo n.º 1
0
def test_merge_files_arg_files_none(file_system):
    """
    Test it dont merge files if no files is given
    """
    output_file = (file_system["main"]["dir"] / "output.txt").as_posix()
    ran_success = MergeFiles.merge_files(output_file, None)
    assert not ran_success, "Expected to return False"
Exemplo n.º 2
0
def test_merge_files_invalid_files(file_system):
    """
    Test it returns false if no valid files is given
    """
    test_files = ["invalid/test1.txt", "invalid/test2.txt"]
    output_file = (file_system["main"]["dir"] / "output.txt").as_posix()
    ran_success = MergeFiles.merge_files(output_file, test_files)
    assert not ran_success, "Expected to return False"
Exemplo n.º 3
0
def test_merge_files_invalid_new_path(file_system):
    """
    Test it returns false if no valid path is given for ned file
    """
    test_files = []
    test_files.append(file_system["main"]["file1"].as_posix())
    test_files.append(file_system["main"]["file2"].as_posix())
    test_files.append(file_system["main"]["file3"].as_posix())
    output_file = "Invalid/path.txt"
    ran_success = MergeFiles.merge_files(output_file, test_files)
    assert not ran_success, "Expected to return False"
Exemplo n.º 4
0
def test_merge_files_arg_new_filepath_none(file_system):
    """
    Test it dont merge files if new_file_path is none
    """
    test_files = []
    test_files.append(file_system["main"]["file1"].as_posix())
    test_files.append(file_system["main"]["file2"].as_posix())
    test_files.append(file_system["main"]["file3"].as_posix())

    ran_success = MergeFiles.merge_files(None, test_files)
    assert not ran_success, "Expected to return False"
Exemplo n.º 5
0
def test_merge_files(file_system):
    """
    Test can merge files
    """
    test_files = []
    test_files.append(file_system["main"]["file1"].as_posix())
    test_files.append(file_system["main"]["file2"].as_posix())
    test_files.append(file_system["main"]["file3"].as_posix())

    output_file = (file_system["main"]["dir"] / "output.txt")

    ran_success = MergeFiles.merge_files(output_file, test_files)
    assert ran_success, "Expected to return True"
    assert output_file.exists()

    output_file = output_file.as_posix()

    result = []
    with open(output_file, 'r') as file_read:
        for line in file_read:
            result.append(line)

    expected_result = ["1\n", "2\n", "3\n"]
    assert result == expected_result