Files
dvc/tests/func/test_analytics.py
T
Casper da Costa-Luis 2bb7257a06 lint: isort pre-commit & misc improvements (#3749)
* test: clean flake8 config root clutter

* test: pre-commit: add isort

Compatible with black (see https://github.com/timothycrosley/isort/issues/694)

* lint: reorder imports

* lint: more complex imports

* lint: fix deepsource

* config: isort: add first party dvc

* tests: restyled: add isort

* temp commit to revert before merge

* Revert "temp commit to revert before merge"

This reverts commit 11db0fd8e95fe891597cbb9bf804480909b19e24.
2020-05-06 23:56:07 +03:00

45 lines
1.0 KiB
Python

import mock
from dvc.analytics import _scm_in_use
from dvc.compat import fspath
from dvc.main import main
from dvc.repo import Repo
@mock.patch("dvc.analytics.send")
def test_daemon_analytics(mock_send, tmp_path):
report = fspath(tmp_path)
assert 0 == main(["daemon", "analytics", report])
mock_send.assert_called_with(report)
@mock.patch("dvc.analytics.collect_and_send_report")
@mock.patch("dvc.analytics.is_enabled", return_value=True)
def test_main_analytics(mock_is_enabled, mock_report, tmp_dir, dvc):
tmp_dir.gen("foo", "text")
assert 0 == main(["add", "foo"])
assert mock_is_enabled.called
assert mock_report.called
def test_scm_dvc_only(tmp_dir, dvc):
scm = _scm_in_use()
assert scm == "NoSCM"
def test_scm_git(tmp_dir, scm, dvc):
scm = _scm_in_use()
assert scm == "Git"
def test_scm_subrepo(tmp_dir, scm):
subdir = tmp_dir / "subdir"
subdir.mkdir()
with subdir.chdir():
Repo.init(subdir=True)
scm = _scm_in_use()
assert scm == "Git"