mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
analytics: define report schema and use it on tests
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user