コード例 #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
コード例 #2
0
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
コード例 #3
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()
コード例 #4
0
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()
コード例 #5
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
コード例 #6
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)
コード例 #7
0
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
コード例 #8
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)