1
0

test_telemetry.py 1.3 KB

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