def test__create_number_from_bits_with_address(self): # The bit_list from the spec looks like: # bit_list_with_address = [ # 0, 0, 0, 0, 0, 0, 0, 0, # 1, 1, 1, 1, 1, 1, 1, 1, # 1, 0, 1, 1, 0, 1, 0, 1, # 0, 1, 0, 0, 1, 0, 1, 0 # ] # Which has no address # The following adds an address of one, which checks that the LSB is being set first # That will create an address of 1 and the same message value of 173 # Must remember to flip the corresponding bit in the inverse byte address = 1 command = 173 bit_list_with_address = TestNecDecoder.reference_bits[:] bit_list_with_address[0] = 1 bit_list_with_address[8] = 0 decoder = NecDecoder() number_returned = decoder._create_number_from_bits( bit_list_with_address) input_command = address << 8 | command assert number_returned == input_command
def test__create_number_from_bits_spec(self): decoder = NecDecoder() assert decoder._create_number_from_bits( TestNecDecoder.reference_bits) == TestNecDecoder.reference_number