def test_partial_push_n_pull(dvc_repo, repo_dir, caplog): assert main(["remote", "add", "-d", "upstream", get_local_url()]) == 0 # Recreate the repo to reread config repo = dvc_repo.__class__(dvc_repo.root_dir) remote = repo.cloud.get_remote("upstream") foo = repo.add(repo_dir.FOO)[0].outs[0] bar = repo.add(repo_dir.BAR)[0].outs[0] # Faulty upload version, failing on foo original = RemoteLOCAL._upload def unreliable_upload(self, from_file, to_info, name=None, **kwargs): if name == "foo": raise Exception("stop foo") return original(self, from_file, to_info, name, **kwargs) with patch.object(RemoteLOCAL, "_upload", unreliable_upload): assert main(["push"]) == 1 assert str(get_last_exc(caplog)) == "1 files failed to upload" assert not remote.exists(remote.checksum_to_path_info(foo.checksum)) assert remote.exists(remote.checksum_to_path_info(bar.checksum)) # Push everything and delete local cache assert main(["push"]) == 0 shutil.rmtree(repo.cache.local.cache_dir) with patch.object(RemoteLOCAL, "_download", side_effect=Exception): assert main(["pull"]) == 1 assert str(get_last_exc(caplog)) == "2 files failed to download"
def test(self): test_get_file_checksum = spy(RemoteLOCAL.get_file_checksum) with patch.object(RemoteLOCAL, "get_file_checksum", test_get_file_checksum): url = get_local_url() ret = main(["remote", "add", "-d", TEST_REMOTE, url]) self.assertEqual(ret, 0) ret = main(["config", "cache.type", "hardlink"]) self.assertEqual(ret, 0) ret = main(["add", self.FOO]) self.assertEqual(ret, 0) ret = main(["push"]) self.assertEqual(ret, 0) ret = main(["run", "-d", self.FOO, "echo foo"]) self.assertEqual(ret, 0) self.assertEqual(test_get_file_checksum.mock.call_count, 1)
def _test(self): url = get_local_url() self.main(["remote", "add", "-d", TEST_REMOTE, url]) stage = self.dvc.run(outs=["bar"], cmd="echo bar > bar") self.main(["push"]) stage_file_path = stage.relpath content = load_stage_file(stage_file_path) del content["outs"][0]["md5"] dump_stage_file(stage_file_path, content) with self._caplog.at_level(logging.WARNING, logger="dvc"): self._caplog.clear() self.main(["status", "-c"]) expected_warning = ( "Output 'bar'(Stage: 'bar.dvc') is missing version info." " Cache for it will not be collected." " Use dvc repro to get your pipeline up to date.") assert expected_warning in self._caplog.text
def _get_url(self): self.dname = get_local_url() return self.dname
def _test(self): url = get_local_url() self.main(["remote", "add", TEST_REMOTE, url]) self._test_cloud(TEST_REMOTE)