Files
dvc/tests/func/metrics/test_common.py
T
Paweł Redzyński 9940540917 metrics/plots: test metrics collection on no target on revision (#4789)
* metrics: include revision information when collecting metrics files

* plots: test warning message on no plot on revision

* plots/metrics: move to one package, introduce common tests

* tests: fix utils placement
2020-10-30 02:00:09 +02:00

30 lines
787 B
Python

import logging
import pytest
from tests.func.metrics.utils import _write_json
def metrics_diff(dvc, filename, revision):
dvc.metrics.diff(targets=[filename], a_rev=revision)
def plots_diff(dvc, filename, revision):
dvc.plots.diff(targets=[filename], revs=[revision])
@pytest.mark.parametrize(
"diff_fun, metric_value",
((metrics_diff, {"m": 1}), (plots_diff, [{"m": 1}, {"m": 2}])),
)
def test_diff_no_file_on_target_rev(
tmp_dir, scm, dvc, caplog, diff_fun, metric_value
):
with tmp_dir.branch("new_branch", new=True):
_write_json(tmp_dir, metric_value, "metric.json")
with caplog.at_level(logging.WARNING, "dvc"):
diff_fun(dvc, "metric.json", "master")
assert "'metric.json' was not found at: 'master'." in caplog.text