test_telemetry.py 1.0 KB

123456789101112131415161718192021222324252627282930
  1. from packaging.version import parse as parse_python_version
  2. from reflex.utils import telemetry
  3. def test_telemetry():
  4. """Test that telemetry is sent correctly."""
  5. # Check that the user OS is one of the supported operating systems.
  6. user_os = telemetry.get_os()
  7. assert user_os is not None
  8. assert user_os in ["Linux", "Darwin", "Java", "Windows"]
  9. # Check that the CPU count and memory are greater than 0.
  10. assert telemetry.get_cpu_count() > 0
  11. # Check that the available memory is greater than 0
  12. assert telemetry.get_memory() > 0
  13. # Check that the Reflex version is not None.
  14. assert telemetry.get_reflex_version() is not None
  15. # Check that the Python version is greater than 3.7.
  16. python_version = telemetry.get_python_version()
  17. assert python_version is not None
  18. assert parse_python_version(python_version) >= parse_python_version("3.7")
  19. def test_disable():
  20. """Test that disabling telemetry works."""
  21. assert not telemetry.send("test", telemetry_enabled=False)