test_telemetry.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. assert tel.user_os is not None
  10. assert tel.user_os in ["Linux", "Darwin", "Java", "Windows"]
  11. # Check that the CPU count and memory are greater than 0.
  12. assert tel.cpu_count > 0
  13. # Check that the available memory is greater than 0
  14. assert tel.memory > 0
  15. # Check that the Pynecone version is not None.
  16. assert tel.pynecone_version is not None
  17. # Check that the Python version is greater than 3.7.
  18. assert tel.python_version is not None
  19. assert versiontuple(tel.python_version) >= versiontuple("3.7")
  20. # Check the json method.
  21. tel_json = json.loads(tel.json())
  22. assert tel_json["user_os"] == tel.user_os
  23. assert tel_json["cpu_count"] == tel.cpu_count
  24. assert tel_json["memory"] == tel.memory
  25. assert tel_json["pynecone_version"] == tel.pynecone_version
  26. assert tel_json["python_version"] == tel.python_version