analytics: send remote types and git-remote's path hashes (#10816)

This commit is contained in:
skshetry
2025-07-28 15:07:41 +05:45
committed by GitHub
parent ba1281a41c
commit dc13186759
4 changed files with 135 additions and 25 deletions
+17 -6
View File
@@ -2,6 +2,7 @@ import os
import pytest
from dvc import __version__, env
from dvc.analytics import _scm_in_use, collect_and_send_report
from dvc.cli import main
from dvc.repo import Repo
@@ -33,7 +34,8 @@ def mock_daemon(mocker):
return mocker.patch("dvc.daemon.daemon", mocker.MagicMock(side_effect=func))
def test_collect_and_send_report(mocker, dvc, mock_daemon):
def test_collect_and_send_report(monkeypatch, mocker, dvc, mock_daemon):
monkeypatch.delenv(env.DVC_ANALYTICS_ENDPOINT, raising=False)
mock_post = mocker.patch("requests.post")
collect_and_send_report()
@@ -41,19 +43,28 @@ def test_collect_and_send_report(mocker, dvc, mock_daemon):
assert mock_post.call_count == 1
assert mock_post.call_args == mocker.call(
"https://analytics.dvc.org",
json=ANY(dict),
json={
"dvc_version": __version__,
"scm_class": type(dvc.scm).__name__,
"is_binary": False,
"system_info": ANY(dict),
"user_id": ANY(str),
"group_id": mocker.ANY,
"remotes": ANY(list),
"git_remote_hash": None,
},
headers={"content-type": "application/json"},
timeout=5,
)
def test_scm_dvc_only(tmp_dir, dvc):
scm = _scm_in_use()
scm = _scm_in_use(dvc.scm)
assert scm == "NoSCM"
def test_scm_git(tmp_dir, scm, dvc):
scm = _scm_in_use()
scm = _scm_in_use(scm)
assert scm == "Git"
@@ -62,7 +73,7 @@ def test_scm_subrepo(tmp_dir, scm):
subdir.mkdir()
with subdir.chdir():
Repo.init(subdir=True)
scm = _scm_in_use()
repo = Repo.init(subdir=True)
scm = _scm_in_use(repo.scm)
assert scm == "Git"