Esempio n. 1
0
def test_load_when_lockfile_is_corrupted(tmp_dir, dvc, corrupt_data):
    with open("Dvcfile.lock", "w+") as f:
        yaml.dump(corrupt_data, f)
    lockfile = Lockfile(dvc, "Dvcfile.lock")
    with pytest.raises(LockfileCorruptedError) as exc_info:
        lockfile.load()
    assert "Dvcfile.lock" in str(exc_info.value)
Esempio n. 2
0
def test_stage_dump_with_deps_and_outs(tmp_dir, dvc):
    data = {
        "s1": {
            "cmd": "command",
            "deps": [{
                "md5": "1.txt",
                "path": "checksum"
            }],
            "outs": [{
                "md5": "2.txt",
                "path": "checksum"
            }],
        }
    }
    dump_yaml("path.lock", data)
    lockfile = Lockfile(dvc, "path.lock")
    stage = PipelineStage(name="s2", repo=dvc, path="path", cmd="command2")
    lockfile.dump(stage)
    assert lockfile.load() == {
        "schema": "2.0",
        "stages": {
            **data, "s2": {
                "cmd": "command2"
            }
        },
    }
Esempio n. 3
0
def test_stage_dump_no_outs_deps(tmp_dir, dvc):
    stage = PipelineStage(name="s1", repo=dvc, path="path", cmd="command")
    lockfile = Lockfile(dvc, "path.lock")
    lockfile.dump(stage)
    assert lockfile.load() == {
        "schema": "2.0",
        "stages": {"s1": {"cmd": "command"}},
    }
Esempio n. 4
0
def test_stage_overwrites_if_already_exists(tmp_dir, dvc):
    lockfile = Lockfile(dvc, "path.lock",)
    stage = PipelineStage(name="s2", repo=dvc, path="path", cmd="command2")
    lockfile.dump(stage)
    stage = PipelineStage(name="s2", repo=dvc, path="path", cmd="command3")
    lockfile.dump(stage)
    assert lockfile.load() == {
        "s2": {"cmd": "command3"},
    }
Esempio n. 5
0
def test_stage_dump_when_already_exists(tmp_dir, dvc):
    data = {"s1": {"cmd": "command", "deps": [], "outs": []}}
    dump_yaml("path.lock", data)
    stage = PipelineStage(name="s2", repo=dvc, path="path", cmd="command2")
    lockfile = Lockfile(dvc, "path.lock")
    lockfile.dump(stage)
    assert lockfile.load() == {
        "schema": "2.0",
        "stages": {**data, "s2": {"cmd": "command2"}},
    }
Esempio n. 6
0
def test_stage_dump_when_already_exists(tmp_dir, dvc):
    data = {"s1": {"cmd": "command", "deps": [], "outs": []}}
    with open("path.lock", "w+") as f:
        yaml.dump(data, f)
    stage = PipelineStage(name="s2", repo=dvc, path="path", cmd="command2")
    lockfile = Lockfile(dvc, "path.lock")
    lockfile.dump(stage)
    assert lockfile.load() == {
        **data,
        "s2": {"cmd": "command2"},
    }