1
0

test_telemetry.py 1017 B

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