mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
analytics: collect execution info only when available
This commit is contained in:
@@ -6,6 +6,7 @@ import json
|
||||
from voluptuous import Schema, Any
|
||||
|
||||
from dvc import analytics
|
||||
from dvc.cli import parse_args
|
||||
from dvc.utils.compat import str, builtin_str
|
||||
|
||||
|
||||
@@ -23,6 +24,30 @@ def tmp_global_config(tmp_path):
|
||||
yield
|
||||
|
||||
|
||||
@mock.patch("dvc.daemon._spawn")
|
||||
@mock.patch("json.dump")
|
||||
def test_collect_and_send_report(mock_json, mock_daemon, tmp_global_config):
|
||||
analytics.collect_and_send_report()
|
||||
report = mock_json.call_args[0][0]
|
||||
|
||||
with pytest.raises(KeyError):
|
||||
report["cmd_class"]
|
||||
|
||||
with pytest.raises(KeyError):
|
||||
report["cmd_return_code"]
|
||||
|
||||
args = parse_args(['add', 'foo'])
|
||||
return_code = 0
|
||||
|
||||
analytics.collect_and_send_report(args, return_code)
|
||||
report = mock_json.call_args[0][0]
|
||||
|
||||
assert report["cmd_class"] == "CmdAdd"
|
||||
assert report["cmd_return_code"] == return_code
|
||||
|
||||
assert mock_daemon.call_count == 2
|
||||
|
||||
|
||||
def test_runtime_info(tmp_global_config):
|
||||
schema = Schema(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user