Files
dvc/tests/unit/command/test_plots.py
T
Alexander Schepanovski 9a55b909f8 Rename --xlab to --x-label, X_TITLE to X_LABEL, same for y (#3948)
Renamed:
- cli options
- dvcfile plot props
- template anchors
- variable names throughout the code
2020-06-03 20:30:17 +03:00

105 lines
2.3 KiB
Python

from dvc.cli import parse_args
from dvc.command.plots import CmdPlotsDiff, CmdPlotsShow
def test_metrics_diff(dvc, mocker):
cli_args = parse_args(
[
"plots",
"diff",
"--out",
"result.extension",
"-t",
"template",
"--targets",
"datafile",
"--show-vega",
"-x",
"x_field",
"-y",
"y_field",
"--title",
"my_title",
"--x-label",
"x_title",
"--y-label",
"y_title",
"HEAD",
"tag1",
"tag2",
]
)
assert cli_args.func == CmdPlotsDiff
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.plots.diff.diff", return_value={"datafile": "filledtemplate"}
)
assert cmd.run() == 0
m.assert_called_once_with(
cmd.repo,
targets=["datafile"],
revs=["HEAD", "tag1", "tag2"],
props={
"template": "template",
"x": "x_field",
"y": "y_field",
"title": "my_title",
"x_label": "x_title",
"y_label": "y_title",
},
)
def test_metrics_show(dvc, mocker):
cli_args = parse_args(
[
"plots",
"show",
"-o",
"result.extension",
"-t",
"template",
"--show-vega",
"--no-csv-header",
"datafile",
]
)
assert cli_args.func == CmdPlotsShow
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.plots.show.show", return_value={"datafile": "filledtemplate"}
)
assert cmd.run() == 0
m.assert_called_once_with(
cmd.repo,
targets=["datafile"],
props={"template": "template", "csv_header": False},
)
def test_plots_show_vega(dvc, mocker, caplog):
cli_args = parse_args(
[
"plots",
"diff",
"HEAD~10",
"HEAD~1",
"--show-vega",
"--targets",
"plots.csv",
]
)
cmd = cli_args.func(cli_args)
mocker.patch(
"dvc.repo.plots.diff.diff", return_value={"plots.csv": "plothtml"}
)
assert cmd.run() == 0
assert "plothtml" in caplog.text