mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
status: add option to skip imports (#10277)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc.cli import main
|
||||
from dvc.fs import localfs
|
||||
|
||||
@@ -30,19 +32,25 @@ def test_implied_cloud(dvc, mocker):
|
||||
assert mock_status.called
|
||||
|
||||
|
||||
def test_status_non_dvc_repo_import(tmp_dir, dvc, git_dir):
|
||||
@pytest.mark.parametrize("check_updates", [True, False])
|
||||
def test_status_non_dvc_repo_import(tmp_dir, dvc, git_dir, check_updates):
|
||||
with git_dir.branch("branch", new=True):
|
||||
git_dir.scm_gen("file", "first version", commit="first version")
|
||||
|
||||
dvc.imp(os.fspath(git_dir), "file", "file", rev="branch")
|
||||
|
||||
assert dvc.status(["file.dvc"]) == {}
|
||||
assert dvc.status(["file.dvc"], check_updates=check_updates) == {}
|
||||
|
||||
with git_dir.branch("branch", new=False):
|
||||
git_dir.scm_gen("file", "second version", commit="update file")
|
||||
|
||||
(status,) = dvc.status(["file.dvc"])["file.dvc"]
|
||||
assert status == {"changed deps": {f"file ({git_dir})": "update available"}}
|
||||
status = dvc.status(["file.dvc"], check_updates=check_updates)
|
||||
if check_updates:
|
||||
assert status == {
|
||||
"file.dvc": [{"changed deps": {f"file ({git_dir})": "update available"}}]
|
||||
}
|
||||
else:
|
||||
assert status == {}
|
||||
|
||||
|
||||
def test_status_before_and_after_dvc_init(tmp_dir, dvc, git_dir):
|
||||
|
||||
@@ -41,6 +41,7 @@ def test_cloud_status(tmp_dir, dvc, mocker):
|
||||
all_commits=True,
|
||||
with_deps=True,
|
||||
recursive=True,
|
||||
check_updates=True,
|
||||
)
|
||||
|
||||
|
||||
@@ -117,3 +118,26 @@ def test_status_up_to_date(dvc, mocker, capsys, cloud_opts, expected_message):
|
||||
assert cmd.run() == 0
|
||||
captured = capsys.readouterr()
|
||||
assert expected_message in captured.out
|
||||
|
||||
|
||||
def test_status_check_updates(dvc, mocker, capsys):
|
||||
cli_args = parse_args(["status", "--no-updates"])
|
||||
assert cli_args.func == CmdDataStatus
|
||||
|
||||
cmd = cli_args.func(cli_args)
|
||||
m = mocker.patch.object(cmd.repo, "status", autospec=True, return_value={})
|
||||
|
||||
assert cmd.run() == 0
|
||||
|
||||
m.assert_called_once_with(
|
||||
cloud=False,
|
||||
targets=[],
|
||||
jobs=None,
|
||||
remote=None,
|
||||
all_branches=False,
|
||||
all_tags=False,
|
||||
all_commits=False,
|
||||
with_deps=False,
|
||||
recursive=False,
|
||||
check_updates=False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user