Skip to content

Commit

Permalink
tests: add unit test for analytics.system_info
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr. Outis committed Dec 5, 2019
1 parent ede0103 commit 7a3aae1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/unit/test_analytics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
import mock
import platform
import json

from voluptuous import Schema, Any

Expand Down Expand Up @@ -65,6 +67,36 @@ def test_is_enabled(dvc_repo, config, result, monkeypatch):
assert result == analytics.is_enabled()


def test_system_info():
schema = Schema({"os": Any("windows", "mac", "linux")})

system = platform.system()

if system == "Windows":
schema = schema.extend(
{
"windows_version_build": int,
"windows_version_major": int,
"windows_version_minor": int,
"windows_version_service_pack": str,
}
)

if system == "Darwin":
schema = schema.extend({"mac_version": str})

if system == "Linux":
schema = schema.extend(
{
"linux_distro": str,
"linux_distro_like": Any(str, None),
"linux_distro_version": Any(str, None),
}
)

assert schema(analytics.system_info())


def test_find_or_create_user_id(tmp_global_config):
created = analytics.find_or_create_user_id()
found = analytics.find_or_create_user_id()
Expand Down

0 comments on commit 7a3aae1

Please sign in to comment.