mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
queue status: add some unit test to increase the coverage
Followed by #7903 Add a new unit test to increase the coverage of test Co-authored-by: Peter Rowlands (변기호) <[email protected]>
This commit is contained in:
committed by
Peter Rowlands (변기호)
co-authored by
Peter Rowlands
parent
e5b4946309
commit
bd74172633
@@ -1,3 +1,5 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
from dvc.cli import parse_args
|
from dvc.cli import parse_args
|
||||||
from dvc.commands.queue.kill import CmdQueueKill
|
from dvc.commands.queue.kill import CmdQueueKill
|
||||||
from dvc.commands.queue.logs import CmdQueueLogs
|
from dvc.commands.queue.logs import CmdQueueLogs
|
||||||
@@ -99,7 +101,55 @@ def test_experiments_stop(dvc, scm, mocker):
|
|||||||
m.assert_called_once_with(kill=True)
|
m.assert_called_once_with(kill=True)
|
||||||
|
|
||||||
|
|
||||||
def test_experiments_status(dvc, scm, mocker, capsys, caplog):
|
@pytest.mark.parametrize(
|
||||||
|
"worker_status, output",
|
||||||
|
[
|
||||||
|
(
|
||||||
|
{"worker1": [], "worker2": []},
|
||||||
|
"No worker active, 2 workers idle at present.",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"worker1": [{"id": "1"}],
|
||||||
|
"worker2": [{"id": "2"}],
|
||||||
|
"worker3": [],
|
||||||
|
},
|
||||||
|
"There are 2 workers active, 1 worker idle at present.",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"worker1": [{"id": "1"}]},
|
||||||
|
"There is 1 worker active, no worker idle at present.",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_worker_status(dvc, scm, worker_status, output, mocker, capsys):
|
||||||
|
|
||||||
|
cli_args = parse_args(
|
||||||
|
[
|
||||||
|
"queue",
|
||||||
|
"status",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
assert cli_args.func == CmdQueueStatus
|
||||||
|
|
||||||
|
cmd = cli_args.func(cli_args)
|
||||||
|
mocker.patch(
|
||||||
|
"dvc.repo.experiments.queue.local.LocalCeleryQueue.status",
|
||||||
|
return_value=[],
|
||||||
|
)
|
||||||
|
m = mocker.patch(
|
||||||
|
"dvc.repo.experiments.queue.local.LocalCeleryQueue.worker_status",
|
||||||
|
return_value=worker_status,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert cmd.run() == 0
|
||||||
|
m.assert_called_once_with()
|
||||||
|
log, _ = capsys.readouterr()
|
||||||
|
assert "No experiments in task queue for now." in log
|
||||||
|
assert output in log
|
||||||
|
|
||||||
|
|
||||||
|
def test_experiments_status(dvc, scm, mocker, capsys):
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
cli_args = parse_args(
|
cli_args = parse_args(
|
||||||
|
|||||||
Reference in New Issue
Block a user