Skip to content

Commit

Permalink
add a regression test for iterative#10309 (iterative#10369)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Mar 23, 2024
1 parent 4f4e977 commit fb628bf
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import logging
import os
import shutil
from os.path import join

import pytest

import dvc_data
from dvc.cli import main
from dvc.exceptions import CheckoutError
from dvc.repo.open_repo import clean_repos
from dvc.scm import CloneError
from dvc.stage.exceptions import StageNotFound
from dvc.testing.remote_tests import TestRemote # noqa: F401
from dvc.utils.fs import remove
Expand Down Expand Up @@ -592,3 +594,35 @@ def test_pull_allow_missing(tmp_dir, dvc, local_remote):

stats = dvc.pull(allow_missing=True)
assert stats["fetched"] == 1


def test_pull_granular_excluding_import_that_cannot_be_pulled(
tmp_dir, dvc, local_remote, mocker
):
"""Regression test for https://github.com/iterative/dvc/issues/10309."""

mocker.patch("dvc.fs.dvc._DVCFileSystem", side_effect=CloneError("SCM error"))
(stage,) = tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}})
imp_stage = dvc.imp(
"https://user:[email protected]/iterative/dvc.git",
"dir",
out="new_dir",
rev="HEAD",
no_exec=True,
)
dvc.push()

shutil.rmtree("dir")
dvc.cache.local.clear()

assert dvc.pull(stage.addressing) == {
"added": [join("dir", "")],
"deleted": [],
"modified": [],
"fetched": 3,
}

with pytest.raises(CloneError, match="SCM error"):
dvc.pull()
with pytest.raises(CloneError, match="SCM error"):
dvc.pull(imp_stage.addressing)

0 comments on commit fb628bf

Please sign in to comment.