예제 #1
0
파일: test_dvc.py 프로젝트: jear/dvc
def test_open_dirty_no_hash(tmp_dir, dvc):
    tmp_dir.gen("file", "file")
    (tmp_dir / "file.dvc").write_text("outs:\n- path: file\n")

    fs = DvcFileSystem(repo=dvc)
    with fs.open("file", "r") as fobj:
        assert fobj.read() == "file"
예제 #2
0
파일: test_dvc.py 프로젝트: jear/dvc
def test_open_dirty_hash(tmp_dir, dvc):
    tmp_dir.dvc_gen("file", "file")
    (tmp_dir / "file").write_text("something")

    fs = DvcFileSystem(repo=dvc)
    with fs.open("file", "r") as fobj:
        assert fobj.read() == "something"
예제 #3
0
def test_open(tmp_dir, dvc):
    tmp_dir.gen("foo", "foo")
    dvc.add("foo")
    (tmp_dir / "foo").unlink()

    fs = DvcFileSystem(repo=dvc)
    with fs.open((tmp_dir / "foo").fs_path, "r") as fobj:
        assert fobj.read() == "foo"
예제 #4
0
def test_open(tmp_dir, dvc):
    tmp_dir.gen("foo", "foo")
    dvc.add("foo")
    (tmp_dir / "foo").unlink()

    fs = DvcFileSystem(dvc)
    with fs.open(PathInfo(tmp_dir) / "foo", "r") as fobj:
        assert fobj.read() == "foo"
예제 #5
0
def test_open_dirty_hash(tmp_dir, dvc):
    tmp_dir.dvc_gen("file", "file")
    (tmp_dir / "file").write_text("something")

    fs = DvcFileSystem(repo=dvc)
    with fs.open((tmp_dir / "file").fs_path, "r") as fobj:
        # NOTE: Unlike RepoFileSystem, DvcFileSystem should not
        # be affected by a dirty workspace.
        assert fobj.read() == "file"
예제 #6
0
def test_open_dirty_no_hash(tmp_dir, dvc):
    tmp_dir.gen("file", "file")
    (tmp_dir / "file.dvc").write_text("outs:\n- path: file\n")

    fs = DvcFileSystem(repo=dvc)
    # NOTE: Unlike RepoFileSystem, DvcFileSystem should not
    # be affected by a dirty workspace.
    with pytest.raises(FileNotFoundError):
        with fs.open((tmp_dir / "file").fs_path, "r"):
            pass
예제 #7
0
def test_open_no_remote(tmp_dir, dvc):
    tmp_dir.dvc_gen("file", "file")
    (tmp_dir / "file").unlink()
    remove(dvc.odb.local.cache_dir)

    fs = DvcFileSystem(repo=dvc)
    with pytest.raises(FileNotFoundError) as exc_info:
        with fs.open((tmp_dir / "file").fs_path, "r"):
            pass
    assert isinstance(exc_info.value.__cause__, NoRemoteError)
예제 #8
0
def test_open_in_history(tmp_dir, scm, dvc):
    tmp_dir.gen("foo", "foo")
    dvc.add("foo")
    dvc.scm.add(["foo.dvc", ".gitignore"])
    dvc.scm.commit("foo")

    tmp_dir.gen("foo", "foofoo")
    dvc.add("foo")
    dvc.scm.add(["foo.dvc", ".gitignore"])
    dvc.scm.commit("foofoo")

    for rev in dvc.brancher(revs=["HEAD~1"]):
        if rev == "workspace":
            continue

        fs = DvcFileSystem(repo=dvc)
        with fs.open((tmp_dir / "foo").fs_path, "r") as fobj:
            assert fobj.read() == "foo"