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

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