Files
dvc/tests/unit/command/test_imp.py
T
Daniele Trifirò 26008f1559 import-url/update: add --no-download flag
add --no-download flag to dvc import-url/dvc update to only create/update .dvc
files without downloading the associated data.

Created .dvc files can be fetched using `dvc pull` or can be
updated using `dvc update --no-download`.
2022-08-23 23:07:01 +03:00

113 lines
2.2 KiB
Python

from dvc.cli import parse_args
from dvc.commands.imp import CmdImport
def test_import(mocker):
cli_args = parse_args(
[
"import",
"repo_url",
"src",
"--out",
"out",
"--file",
"file",
"--rev",
"version",
"--desc",
"description",
"--jobs",
"3",
]
)
assert cli_args.func == CmdImport
cmd = cli_args.func(cli_args)
m = mocker.patch.object(cmd.repo, "imp", autospec=True)
assert cmd.run() == 0
m.assert_called_once_with(
"repo_url",
path="src",
out="out",
fname="file",
rev="version",
no_exec=False,
no_download=False,
desc="description",
jobs=3,
)
def test_import_no_exec(mocker):
cli_args = parse_args(
[
"import",
"repo_url",
"src",
"--out",
"out",
"--file",
"file",
"--rev",
"version",
"--no-exec",
"--desc",
"description",
]
)
cmd = cli_args.func(cli_args)
m = mocker.patch.object(cmd.repo, "imp", autospec=True)
assert cmd.run() == 0
m.assert_called_once_with(
"repo_url",
path="src",
out="out",
fname="file",
rev="version",
no_exec=True,
no_download=False,
desc="description",
jobs=None,
)
def test_import_no_download(mocker):
cli_args = parse_args(
[
"import",
"repo_url",
"src",
"--out",
"out",
"--file",
"file",
"--rev",
"version",
"--no-download",
"--desc",
"description",
]
)
cmd = cli_args.func(cli_args)
m = mocker.patch.object(cmd.repo, "imp", autospec=True)
assert cmd.run() == 0
m.assert_called_once_with(
"repo_url",
path="src",
out="out",
fname="file",
rev="version",
no_exec=False,
no_download=True,
desc="description",
jobs=None,
)