Projet de remplacement du "RPiPasserelle" d'Otec.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_variable_value.py 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python3
  2. import pytest
  3. from datetime import datetime
  4. from pyheatpump.variable_types import app, get_variable_types, set_variable_types, ROUTES
  5. from pyheatpump.models import *
  6. def test_last_update(set_test_db, var_types):
  7. for _, var_type in var_types.items():
  8. for _, variable in var_type.get_variables().items():
  9. try:
  10. if not variable.last_update:
  11. continue
  12. time = datetime.fromtimestamp(variable.last_update)
  13. val = VariableValue.get(variable.type,
  14. variable.address,
  15. time)
  16. assert val is not None
  17. assert variable.last_update == val.time
  18. except StopIteration:
  19. assert False
  20. def test_var_value_getval(set_test_db, var_types):
  21. var_type = var_types['Analog']
  22. for _, variable in var_type.get_variables().items():
  23. try:
  24. if not variable.last_update:
  25. continue
  26. time = datetime.fromtimestamp(variable.last_update)
  27. value = VariableValue.get(var_type,
  28. variable.address,
  29. time).get_value()
  30. assert type(value) == float
  31. except StopIteration:
  32. assert False
  33. """
  34. var_type = var_types['Integer']
  35. for _, variable in var_type.get_variables().items():
  36. try:
  37. if not variable.last_update:
  38. continue
  39. time = datetime.fromtimestamp(variable.last_update)
  40. value = VariableValue.get(var_type,
  41. variable.address,
  42. time).get_value()
  43. assert type(value) == int
  44. except StopIteration:
  45. assert False
  46. var_type = var_types['Digital']
  47. for _, variable in var_type.get_variables().items():
  48. try:
  49. if not variable.last_update:
  50. continue
  51. time = datetime.fromtimestamp(variable.last_update)
  52. value = VariableValue.get(var_type,
  53. variable.address,
  54. time).get_value()
  55. assert type(value) == bool
  56. except StopIteration:
  57. assert False
  58. """