#!/usr/bin/env python3 import pytest from pyheatpump.lib import shift_response def test_shift_response(): heatpump_dict = {} heatpump_dict['Analog'] = { key: (0 if key % 2 == 0 else 1) for key in range(1, 1251) } heatpump_dict['Integer'] = { key: (0 if key % 2 == 0 else 1) for key in range(5002, 6252 ) } heatpump_dict['Digital'] = { key: (0 if key % 2 == 0 else 1 ) for key in range(1, 1001) } assert isinstance(heatpump_dict, dict) shifted = shift_response(heatpump_dict) assert isinstance(shifted, dict) assert 'Analog' in shifted.keys() assert isinstance(shifted['Analog'], dict) analog_keys = list(map(int, shifted['Analog'].keys())) assert min(analog_keys) == 1 assert shifted['Analog']["1"] == 1 assert shifted['Analog']["2"] == 0 assert 'Digital' in shifted.keys() assert isinstance(shifted['Digital'], dict) digital_keys = list(map(int, shifted['Digital'].keys())) assert min(digital_keys) == 1 assert shifted['Digital']["1"] == 1 assert shifted['Digital']["2"] == 0 assert 'Integer' in shifted.keys() assert isinstance(shifted['Integer'], dict) for k in shifted['Integer'].keys(): assert isinstance(k, str) int_keys = list(map(int, shifted['Integer'].keys())) assert min(int_keys) == 1 assert max(int_keys) == 1250 assert shifted['Integer']["1"] == 0 assert shifted['Integer']["2"] == 1