Files
dvc/tests/unit/command/test_compat_flag.py
T
skshetry 8e5f4a8f35 data ls: new command to show metadata with outputs (#8252)
data ls: add new command to show metadata for the outputs
2022-09-09 17:36:24 +05:45

47 lines
1.6 KiB
Python

from itertools import takewhile
import pytest
from dvc.cli import parse_args
def _id_gen(val) -> str:
if isinstance(val, list):
return "-".join(takewhile(lambda v: not v.startswith("-"), val))
return str(val)
@pytest.mark.parametrize(
"args, key",
[
(["dag", "--show-md"], "markdown"),
(["data", "ls", "--show-md"], "markdown"),
(["diff", "--show-json"], "json"),
(["diff", "--show-md"], "markdown"),
(["experiments", "diff", "--show-json"], "json"),
(["experiments", "diff", "--show-md"], "markdown"),
(["experiments", "show", "--show-json"], "json"),
(["experiments", "show", "--show-csv"], "csv"),
(["experiments", "show", "--show-md"], "markdown"),
(["ls", "--show-json", "."], "json"),
(["metrics", "diff", "--show-json"], "json"),
(["metrics", "diff", "--show-md"], "markdown"),
(["metrics", "show", "--show-json"], "json"),
(["metrics", "show", "--show-md"], "markdown"),
(["params", "diff", "--show-json"], "json"),
(["params", "diff", "--show-md"], "markdown"),
(["status", "--show-json"], "json"),
(["plots", "show", "--show-json"], "json"),
(["plots", "diff", "--show-json"], "json"),
(["exp", "list", "--names-only"], "name_only"),
(["stage", "list", "--names-only"], "name_only"),
(["data", "status", "--json"], "json"),
],
ids=_id_gen,
)
def test_backward_compat_flags(args, key):
"""Test support for flags kept for backward compatibility."""
cli_args = parse_args(args)
d = vars(cli_args)
assert d[key] is True