Ejemplo n.º 1
0
def test_str_workdir_inside_repo(dvc):
    stage = Stage(dvc)
    output = Output(stage, "path", cache=False)

    assert "path" == str(output)

    stage = Stage(dvc, wdir="some_folder")
    output = Output(stage, "path", cache=False)

    assert os.path.join("some_folder", "path") == str(output)
Ejemplo n.º 2
0
def test_str_on_external_absolute_path(dvc):
    stage = Stage(dvc)

    rel_path = os.path.join("..", "path", "to", "file")
    abs_path = os.path.abspath(rel_path)
    output = Output(stage, abs_path, cache=False)

    assert output.def_path == abs_path
    assert output.path_info.fspath == abs_path
    assert str(output) == abs_path
Ejemplo n.º 3
0
def test_get_used_objs(exists, expected_message, mocker, caplog):
    stage = mocker.MagicMock()
    mocker.patch.object(stage, "__str__", return_value="stage: 'stage.dvc'")
    mocker.patch.object(stage, "addressing", "stage.dvc")
    mocker.patch.object(stage, "wdir", os.getcwd())
    mocker.patch.object(stage.repo, "root_dir", os.getcwd())
    mocker.patch.object(stage.repo.dvcignore, "is_ignored", return_value=False)
    mocker.patch.object(stage.repo.dvcignore,
                        "check_ignore",
                        return_value=_no_match("path"))

    output = Output(stage, "path")

    mocker.patch.object(output, "use_cache", True)
    mocker.patch.object(stage, "is_repo_import", False)
    mocker.patch.object(Output, "exists",
                        new_callable=mocker.PropertyMock).return_value = exists

    with caplog.at_level(logging.WARNING, logger="dvc"):
        assert {} == output.get_used_objs()
    assert first(caplog.messages) == expected_message
Ejemplo n.º 4
0
 def _get_output(self):
     stage = Stage(self.dvc)
     return Output(stage, "path")
Ejemplo n.º 5
0
def test_str_workdir_outside_repo(tmp_dir, erepo_dir):
    stage = Stage(erepo_dir.dvc)
    output = Output(stage, "path", cache=False)

    assert relpath("path", erepo_dir.dvc.root_dir) == str(output)
Ejemplo n.º 6
0
def test_save_missing(dvc, mocker):
    stage = Stage(dvc)
    out = Output(stage, "path", cache=False)
    with mocker.patch.object(out.fs, "exists", return_value=False):
        with pytest.raises(out.DoesNotExistError):
            out.save()