Skip to content

Commit

Permalink
fix/8550+: cover with test
Browse files Browse the repository at this point in the history
  • Loading branch information
shcheklein authored and skshetry committed Nov 16, 2022
1 parent d52e1aa commit 76cc649
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tests/func/experiments/test_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def test_packed_args_exists(tmp_dir, scm, dvc, exp_stage, caplog):
assert "Temporary DVC file" in caplog.text


def test_list(tmp_dir, scm, dvc, exp_stage):
def _prepare_experiments(tmp_dir, scm, dvc, exp_stage):
baseline_a = scm.get_rev()
results = dvc.experiments.run(exp_stage.addressing, params=["foo=2"])
exp_a = first(results)
Expand All @@ -433,6 +433,18 @@ def test_list(tmp_dir, scm, dvc, exp_stage):
exp_c = first(results)
ref_info_c = first(exp_refs_by_rev(scm, exp_c))

return baseline_a, baseline_c, ref_info_a, ref_info_b, ref_info_c


def test_list(tmp_dir, scm, dvc, exp_stage):
(
baseline_a,
baseline_c,
ref_info_a,
ref_info_b,
ref_info_c,
) = _prepare_experiments(tmp_dir, scm, dvc, exp_stage)

assert dvc.experiments.ls() == {baseline_c: [ref_info_c.name]}

exp_list = dvc.experiments.ls(rev=ref_info_a.baseline_sha)
Expand All @@ -447,6 +459,25 @@ def test_list(tmp_dir, scm, dvc, exp_stage):
}


def test_list_cli(tmp_dir, scm, dvc, capsys, exp_stage):
from dvc.cli import main

baseline_a, _, ref_info_a, ref_info_b, ref_info_c = _prepare_experiments(
tmp_dir, scm, dvc, exp_stage
)

# Make sure that we prioritize the current branch name
scm.checkout("branch", True)

capsys.readouterr()
assert main(["exp", "list", "-A"]) == 0
cap = capsys.readouterr()
assert set(cap.out.split()) == set(
["branch:", baseline_a[:7] + ":"]
+ [ref_info_a.name, ref_info_b.name, ref_info_c.name]
)


def test_subdir(tmp_dir, scm, dvc, workspace):
subdir = tmp_dir / "dir"
subdir.gen("copy.py", COPY_SCRIPT)
Expand Down

0 comments on commit 76cc649

Please sign in to comment.