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_lib.py 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env python3
  2. import pytest
  3. from pyheatpump.lib import shift_response
  4. def test_shift_response():
  5. heatpump_dict = {}
  6. heatpump_dict['Analog'] = {
  7. key: (0 if key % 2 == 0 else 1)
  8. for key in range(1, 1251)
  9. }
  10. heatpump_dict['Integer'] = {
  11. key: (0 if key % 2 == 0 else 1)
  12. for key in range(5002, 6252 )
  13. }
  14. heatpump_dict['Digital'] = {
  15. key: (0 if key % 2 == 0 else 1 )
  16. for key in range(1, 1001)
  17. }
  18. assert isinstance(heatpump_dict, dict)
  19. shifted = shift_response(heatpump_dict)
  20. assert isinstance(shifted, dict)
  21. assert 'Analog' in shifted.keys()
  22. assert isinstance(shifted['Analog'], dict)
  23. analog_keys = list(map(int, shifted['Analog'].keys()))
  24. assert min(analog_keys) == 1
  25. assert shifted['Analog']["1"] == 1
  26. assert shifted['Analog']["2"] == 0
  27. assert 'Digital' in shifted.keys()
  28. assert isinstance(shifted['Digital'], dict)
  29. digital_keys = list(map(int, shifted['Digital'].keys()))
  30. assert min(digital_keys) == 1
  31. assert shifted['Digital']["1"] == 1
  32. assert shifted['Digital']["2"] == 0
  33. assert 'Integer' in shifted.keys()
  34. assert isinstance(shifted['Integer'], dict)
  35. for k in shifted['Integer'].keys():
  36. assert isinstance(k, str)
  37. int_keys = list(map(int, shifted['Integer'].keys()))
  38. assert min(int_keys) == 1
  39. assert max(int_keys) == 1250
  40. assert shifted['Integer']["1"] == 0
  41. assert shifted['Integer']["2"] == 1