Files
dvc/tests/unit/command/test_queue.py
T
karajan1001andPeter Rowlands a6cb4eb72e exp queue: remove queued experiments(#7591)
fix: #7591
1. Add a new command `dvc queue`
2. Add two sub-command `dvc queue remove` and `dvc queue kill`
3. Add a unit test to test them

Co-authored-by: Peter Rowlands (변기호) <[email protected]>
2022-07-12 21:39:49 +09:00

64 lines
1.4 KiB
Python

from dvc.cli import parse_args
from dvc.commands.queue.kill import CmdQueueKill
from dvc.commands.queue.remove import CmdQueueRemove
def test_experiments_remove(dvc, scm, mocker):
cli_args = parse_args(
[
"queue",
"remove",
"--all",
]
)
assert cli_args.func == CmdQueueRemove
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.experiments.queue.local.LocalCeleryQueue.clear",
return_value={},
)
assert cmd.run() == 0
m.assert_called_once_with()
cli_args = parse_args(
[
"queue",
"remove",
"exp1",
"exp2",
]
)
assert cli_args.func == CmdQueueRemove
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.experiments.queue.local.LocalCeleryQueue.remove",
return_value={},
)
assert cmd.run() == 0
m.assert_called_once_with(revs=["exp1", "exp2"])
def test_experiments_kill(dvc, scm, mocker):
cli_args = parse_args(
[
"queue",
"kill",
"exp1",
"exp2",
]
)
assert cli_args.func == CmdQueueKill
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.experiments.queue.local.LocalCeleryQueue.kill",
return_value={},
)
assert cmd.run() == 0
m.assert_called_once_with(revs=["exp1", "exp2"])