Ejemplo n.º 1
0
def test_sort_files_arg_files_none():
    """
    Test it returns empty list if no files to sort
    """
    regex = re.compile(r"no match(\d)")
    sorted_files = MergeFiles.sort_files(None, regex)
    assert not sorted_files
Ejemplo n.º 2
0
def test_sort_files_arg_regex_none():
    """
    Test it returns the same file order if regex is none
    """
    test_files = []
    test_files.append("c:/test/path/test2.txt")
    test_files.append("c:/test/path/test3.txt")
    test_files.append("c:/test/path/test1.txt")
    sorted_files = MergeFiles.sort_files(test_files, None)

    assert len(sorted_files) == 3
    assert sorted_files[0] == "c:/test/path/test2.txt"
    assert sorted_files[1] == "c:/test/path/test3.txt"
    assert sorted_files[2] == "c:/test/path/test1.txt"
Ejemplo n.º 3
0
def test_sort_files_no_regex_match():
    """
    Test it returns the same file order if no match
    """
    regex = re.compile(r"no match(\d)")
    test_files = []
    test_files.append("c:/test/path/test2.txt")
    test_files.append("c:/test/path/test3.txt")
    test_files.append("c:/test/path/test1.txt")
    sorted_files = MergeFiles.sort_files(test_files, regex)

    assert len(sorted_files) == 3
    assert sorted_files[0] == "c:/test/path/test2.txt"
    assert sorted_files[1] == "c:/test/path/test3.txt"
    assert sorted_files[2] == "c:/test/path/test1.txt"
Ejemplo n.º 4
0
def test_sort_files():
    """
    Test can sort files
    """
    regex = re.compile(r".*(\d)")
    test_files = []
    test_files.append("c:/test/path/test2.txt")
    test_files.append("c:/test/path/test3.txt")
    test_files.append("c:/test/path/test1.txt")
    sorted_files = MergeFiles.sort_files(test_files, regex)

    assert len(sorted_files) == 3
    assert sorted_files[0] == "c:/test/path/test1.txt"
    assert sorted_files[1] == "c:/test/path/test2.txt"
    assert sorted_files[2] == "c:/test/path/test3.txt"