mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-07 15:28:28 +01:00
analytics: move report schema to tests
This commit is contained in:
+1
-14
@@ -6,7 +6,6 @@ import sys
|
||||
import uuid
|
||||
|
||||
import distro
|
||||
from voluptuous import Schema, Any
|
||||
|
||||
from dvc import __version__
|
||||
from dvc.config import Config, to_bool
|
||||
@@ -15,23 +14,11 @@ from dvc.lock import Lock, LockError
|
||||
from dvc.repo import Repo
|
||||
from dvc.scm import SCM
|
||||
from dvc.utils import env2bool, is_binary, makedirs
|
||||
from dvc.utils.compat import builtin_str, str, FileNotFoundError, fspath_py35
|
||||
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": Any(builtin_str, str),
|
||||
"is_binary": bool,
|
||||
"scm_class": Any("Git", None),
|
||||
"user_id": Any(builtin_str, str),
|
||||
"system_info": dict,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def collect(args=None, return_code=None):
|
||||
"""
|
||||
|
||||
@@ -2,8 +2,10 @@ import json
|
||||
import pytest
|
||||
import mock
|
||||
|
||||
from voluptuous import Schema, Any
|
||||
|
||||
from dvc import analytics
|
||||
from dvc.utils.compat import str
|
||||
from dvc.utils.compat import str, builtin_str
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -18,8 +20,20 @@ def tmp_global_config(tmp_path):
|
||||
|
||||
|
||||
def test_collect(tmp_global_config):
|
||||
schema = Schema(
|
||||
{
|
||||
"cmd_class": Any(str, None),
|
||||
"cmd_return_code": Any(int, None),
|
||||
"dvc_version": Any(builtin_str, str),
|
||||
"is_binary": bool,
|
||||
"scm_class": Any("Git", None),
|
||||
"user_id": Any(builtin_str, str),
|
||||
"system_info": dict,
|
||||
}
|
||||
)
|
||||
|
||||
report = analytics.collect(return_code=0)
|
||||
assert analytics.report_schema(report)
|
||||
assert schema(report)
|
||||
|
||||
|
||||
@mock.patch("requests.post")
|
||||
|
||||
Reference in New Issue
Block a user