Esempio n. 1
0
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
Esempio n. 2
0
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()
Esempio n. 3
0
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
Esempio n. 4
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)