reflex/tests/test_telemetry.py
Alek Petuskey b36680fefd
Anonymous Telemetry Opt Out Available (#550)
* Added anonymous telemetry with opt-out.
2023-02-16 00:11:53 -08:00

38 lines
1.1 KiB
Python

import json
from pynecone import telemetry
def versiontuple(v):
return tuple(map(int, (v.split("."))))
def test_telemetry():
"""Test that telemetry is sent correctly."""
tel = telemetry.Telemetry()
# Check that the user OS is one of the supported operating systems.
assert tel.user_os is not None
assert tel.user_os in ["Linux", "Darwin", "Java", "Windows"]
# Check that the CPU count and memory are greater than 0.
assert tel.cpu_count > 0
# Check that the available memory is greater than 0
assert tel.memory > 0
# Check that the Pynecone version is not None.
assert tel.pynecone_version is not None
# Check that the Python version is greater than 3.7.
assert tel.python_version is not None
assert versiontuple(tel.python_version) >= versiontuple("3.7")
# Check the json method.
tel_json = json.loads(tel.json())
assert tel_json["user_os"] == tel.user_os
assert tel_json["cpu_count"] == tel.cpu_count
assert tel_json["memory"] == tel.memory
assert tel_json["pynecone_version"] == tel.pynecone_version
assert tel_json["python_version"] == tel.python_version