def test_get_used_cache(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", ".") mocker.patch.object( stage.repo.tree.dvcignore, "is_ignored", return_value=False, ) mocker.patch.object( stage.repo.tree.dvcignore, "check_ignore", return_value=_no_match("path"), ) output = BaseOutput(stage, "path") mocker.patch.object(output, "use_cache", True) mocker.patch.object(stage, "is_repo_import", False) mocker.patch.object(BaseOutput, "exists", new_callable=mocker.PropertyMock).return_value = exists with caplog.at_level(logging.WARNING, logger="dvc"): assert isinstance(output.get_used_cache(), NamedCache) assert first(caplog.messages) == expected_message
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