Files
dvc/tests/unit/command/test_data_sync.py
T
Piotr Bielak 3feaa86696 Pass missing glob flag to pull command (#5354)
The `--glob` flag is parsed from the command line, but in the
`CmdDataPull` class in the invocation the parameter (`self.args.glob`)
is not passed to the `pull` method implementation. Hence, always the
default value (False) is used. This commit fixes this issue and sets the
`glob` parameter properly.
2021-02-01 14:21:21 +02:00

123 lines
2.7 KiB
Python

from dvc.cli import parse_args
from dvc.command.data_sync import CmdDataFetch, CmdDataPull, CmdDataPush
def test_fetch(mocker):
cli_args = parse_args(
[
"fetch",
"target1",
"target2",
"--jobs",
"2",
"--remote",
"remote",
"--all-branches",
"--all-tags",
"--all-commits",
"--with-deps",
"--recursive",
"--run-cache",
]
)
assert cli_args.func == CmdDataFetch
cmd = cli_args.func(cli_args)
m = mocker.patch.object(cmd.repo, "fetch", autospec=True, return_value=0)
assert cmd.run() == 0
m.assert_called_once_with(
targets=["target1", "target2"],
jobs=2,
remote="remote",
all_branches=True,
all_tags=True,
all_commits=True,
with_deps=True,
recursive=True,
run_cache=True,
)
def test_pull(mocker):
cli_args = parse_args(
[
"pull",
"target1",
"target2",
"--jobs",
"2",
"--remote",
"remote",
"--all-branches",
"--all-tags",
"--all-commits",
"--with-deps",
"--force",
"--recursive",
"--run-cache",
"--glob",
]
)
assert cli_args.func == CmdDataPull
cmd = cli_args.func(cli_args)
m = mocker.patch.object(cmd.repo, "pull", autospec=True)
assert cmd.run() == 0
m.assert_called_once_with(
targets=["target1", "target2"],
jobs=2,
remote="remote",
all_branches=True,
all_tags=True,
all_commits=True,
with_deps=True,
force=True,
recursive=True,
run_cache=True,
glob=True,
)
def test_push(mocker):
cli_args = parse_args(
[
"push",
"target1",
"target2",
"--jobs",
"2",
"--remote",
"remote",
"--all-branches",
"--all-tags",
"--all-commits",
"--with-deps",
"--recursive",
"--run-cache",
"--glob",
]
)
assert cli_args.func == CmdDataPush
cmd = cli_args.func(cli_args)
m = mocker.patch.object(cmd.repo, "push", autospec=True, return_value=0)
assert cmd.run() == 0
m.assert_called_once_with(
targets=["target1", "target2"],
jobs=2,
remote="remote",
all_branches=True,
all_tags=True,
all_commits=True,
with_deps=True,
recursive=True,
run_cache=True,
glob=True,
)