Ejemplo n.º 1
0
def test_get_valid_directories(tmp_path):
    fs = DefaultFilesystem()
    fs.touch(tmp_path / "test_file")

    values = {str(tmp_path / "test_file" / "..")}

    result = get_valid_directories(fs, values)

    assert str(result.pop()) == str(tmp_path)
Ejemplo n.º 2
0
def test_parse_path(tmp_path):
    fs = DefaultFilesystem()
    fs.touch(tmp_path / "test_file")

    value = str(tmp_path / "test_file" / "..")

    result = parse_path(fs, value)

    assert result == tmp_path
Ejemplo n.º 3
0
def test_validate_path_directory(tmp_path):
    fs = DefaultFilesystem()

    path = tmp_path / "test_file"
    fs.touch(path)
    paths = {path}

    with pytest.raises(Exception) as e:
        validate_directories(fs, paths)

    assert "is not a directory" in str(e.value)
Ejemplo n.º 4
0
def test_get_valid_paths(tmp_path):
    fs = DefaultFilesystem()
    fs.create_dir(tmp_path / "test_dir")
    fs.touch(tmp_path / "test_file")

    values = {
        str(tmp_path / "test_dir" / ".." / "test_file"),
        str(tmp_path / "test_dir" / ".." / "test_dir"),
    }

    result = get_valid_paths(fs, values)

    assert result == {tmp_path / "test_dir", tmp_path / "test_file"}