def test_null_values(f_mod): vals = generate_encoding_data() vals['offset[delta_degF]'] = None vals['address'] = None f_mod.pre_encode(TempSensorOneWire_pb2.Block(), vals) assert 'address' not in vals
def test_null_values(f_mod): vals = generate_encoding_data() vals['offset[delta_degF]'] = None vals['address'] = None f_mod.encode_options(TempSensorOneWire_pb2.TempSensorOneWire(), vals, CodecOpts()) assert 'address' not in vals
def test_pre_encode_fields(f_mod): vals = generate_encoding_data() f_mod.pre_encode(TempSensorOneWire_pb2.Block(), vals) # converted to (delta) degC # scaled * 256 # rounded to int assert vals == generate_decoding_data()
def test_encode_options(f_mod): vals = generate_encoding_data() f_mod.encode_options(TempSensorOneWire_pb2.TempSensorOneWire(), vals, CodecOpts()) # converted to (delta) degC # scaled * 256 # rounded to int assert vals == generate_decoding_data()
def test_decode_no_system(proc): vals = generate_decoding_data() proc.post_decode(TempSensorOneWire_pb2.Block(), vals, DecodeOpts()) assert vals['offset']['value'] > 0 assert vals['value']['value'] > 0
def test_post_decode_fields(f_mod): vals = generate_decoding_data() f_mod.post_decode(TempSensorOneWire_pb2.Block(), vals, DecodeOpts()) assert vals['offset']['value'] == pytest.approx(20, 0.1) assert vals['value']['value'] == pytest.approx(100, 0.1)
def test_decode_no_system(c_mod): vals = generate_decoding_data() c_mod.decode_options(TempSensorOneWire_pb2.TempSensorOneWire(), vals, CodecOpts()) assert vals['offset']['value'] > 0 assert vals['value']['value'] > 0
def test_decode_options(f_mod): vals = generate_decoding_data() f_mod.decode_options(TempSensorOneWire_pb2.TempSensorOneWire(), vals, CodecOpts()) assert vals['offset']['value'] == pytest.approx(20, 0.1) assert vals['value']['value'] == pytest.approx(100, 0.1)