예제 #1
0
def test_broken_dir_permissions():
    """Testing this is not simple since git doesn't sync dir permissions. So we need to create the dir the first time
    after removing it (if it was checked in by accident).

    Test included to document expected behaviour.
    """
    file_path = os.path.join(data, "correct_paths.txt")
    dir_path = os.path.join(target, "temp_dir")
    try:
        os.rmdir(dir_path)  # Remove if present
    except FileNotFoundError:
        pass

    os.mkdir(dir_path, mode=0o111)  # Execute-only
    with pytest.raises(PermissionError):
        get_images(file_path, dir_path)
예제 #2
0
def test_broken_file_permissions():
    """Testing this is not simple since git doesn't sync file permissions. So we need to create the file the first time
    after removing it (if it was checked in by accident).

    Test included to document expected behaviour.
    """
    file_path = os.path.join(data, "temp_file.txt")
    dir_path = target
    try:
        os.remove(file_path)  # Remove if present
    except FileNotFoundError:
        pass

    with open(file_path, "w") as out_file:
        out_file.write("Some content.")
    os.chmod(file_path, mode=0o111)  # Execute-only
    with pytest.raises(PermissionError):
        get_images(file_path, dir_path)
예제 #3
0
def test_non_images_paths():
    path = f"{data}/correct_paths_with_non_images.txt"
    target_path = target
    faulty = get_images(path, target_path)
    assert not faulty
예제 #4
0
def test_broken_paths():
    path = f"{data}/broken_paths.txt"
    target_path = target
    faulty = get_images(path, target_path)
    assert faulty
예제 #5
0
def test_happy_paths():
    path = f"{data}/correct_paths.txt"
    target_path = target
    faulty = get_images(path, target_path)
    assert not faulty