test_telemetry.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import pytest
  2. from pynecone import telemetry
  3. import json
  4. def versiontuple(v):
  5. return tuple(map(int, (v.split("."))))
  6. def test_telemetry():
  7. """Test that telemetry is sent correctly."""
  8. tel = telemetry.Telemetry()
  9. # Check that the user OS is one of the supported operating systems.
  10. tel.get_os()
  11. assert tel.user_os != None
  12. assert tel.user_os in ["Linux", "Darwin", "Java", "Windows"]
  13. # Check that the CPU count and memory are greater than 0.
  14. tel.get_cpu_count()
  15. assert tel.cpu_count > 0
  16. # Check that the available memory is greater than 0
  17. tel.get_memory()
  18. assert tel.memory > 0
  19. # Check that the Pynecone version is not None.
  20. tel.get_python_version()
  21. assert tel.pynecone_version != None
  22. # Check that the Python version is greater than 3.7.
  23. tel.get_pynecone_version()
  24. assert tel.python_version != None
  25. assert versiontuple(tel.python_version) >= versiontuple("3.7")
  26. # Check the json method.
  27. tel_json = json.loads(tel.json())
  28. assert tel_json["user_os"] == tel.user_os
  29. assert tel_json["cpu_count"] == tel.cpu_count
  30. assert tel_json["memory"] == tel.memory
  31. assert tel_json["pynecone_version"] == tel.pynecone_version
  32. assert tel_json["python_version"] == tel.python_version