analytics: define report schema and use it on tests

This commit is contained in:
Mr. Outis
2019-12-02 21:52:00 -06:00
parent 2c8e1495b8
commit ca485db240
2 changed files with 14 additions and 8 deletions
+13
View File
@@ -6,6 +6,7 @@ import sys
import uuid
import distro
from voluptuous import Schema, Any
from dvc import __version__
from dvc.config import Config, to_bool
@@ -19,6 +20,18 @@ from dvc.utils.compat import str, FileNotFoundError, fspath_py35
logger = logging.getLogger(__name__)
report_schema = Schema(
{
"cmd_class": Any(str, None),
"cmd_return_code": Any(int, None),
"dvc_version": str,
"is_binary": bool,
"scm_class": Any("Git", None),
"user_id": str,
"system_info": dict,
}
)
def collect(args=None, return_code=None):
"""
+1 -8
View File
@@ -19,14 +19,7 @@ def tmp_global_config(tmp_path):
def test_collect(tmp_global_config):
report = analytics.collect(return_code=0)
assert report["cmd_return_code"] == 0
assert report["scm_class"] in ["Git", None]
assert not report["cmd_class"]
assert type(report["is_binary"]) is bool
assert type(report["system_info"]) is dict
assert type(report["dvc_version"]) is builtin_str
assert type(report["user_id"]) is str
assert analytics.report_schema(report)
@mock.patch("requests.post")