Ejemplo n.º 1
0
def test_get_path(tmp_path):
    local = LocalClient(tmp_path)
    path = tmp_path / "foo.txt"
    path_upper = tmp_path / "FOO.TXT"

    # The path does not exist, it returns ROOT
    assert local.get_path(pathlib.Path("bar.doc")) == ROOT

    # The path exists, it returns
    assert local.get_path(path) == pathlib.Path("foo.txt")
    assert local.get_path(path_upper) == pathlib.Path("FOO.TXT")
Ejemplo n.º 2
0
def test_get_path(tmp):
    folder = tmp()
    folder.mkdir()
    local = LocalClient(folder)
    path = folder / "foo.txt"
    path_upper = folder / "FOO.TXT"

    # The path does not exist, it returns ROOT
    assert local.get_path(pathlib.Path("bar.doc")) == ROOT

    # The path exists, it returns
    assert local.get_path(path) == pathlib.Path("foo.txt")
    assert local.get_path(path_upper) == pathlib.Path("FOO.TXT")
Ejemplo n.º 3
0
def test_get_path_permission_error(mocked_resolve, mocked_absolute, tmp):
    folder = tmp()
    folder.mkdir()
    local = LocalClient(folder)
    path = folder / "foo.txt"

    # Path.resolve() raises a PermissionError, it should fallback on .absolute()
    mocked_resolve.side_effect = PermissionError()
    path_abs = local.get_path(path)
    assert mocked_absolute.called

    # Restore the original ehavior and check that .resolved() and .absolute()
    # return the same value.
    mocked_resolve.reset_mock()
    assert local.get_path(path) == path_abs