Exemplo n.º 1
0
def test_invalid_payload():
    """Test for having wrong payload set."""
    frame = CEMIFrame()
    frame.code = CEMIMessageCode.L_DATA_IND
    frame.flags = 0
    frame.payload = None
    frame.src_addr = IndividualAddress(0)
    frame.dst_addr = IndividualAddress(0)

    with pytest.raises(TypeError):
        frame.calculated_length()

    with pytest.raises(ConversionError):
        frame.to_knx()
Exemplo n.º 2
0
def test_invalid_payload():
    """Test for having wrong payload set."""
    frame = CEMIFrame()
    frame.code = CEMIMessageCode.L_DATA_IND
    frame.flags = 0
    frame.mpdu_len = 1
    frame.payload = DPTBinary(1)
    frame.src_addr = IndividualAddress(0)
    frame.dst_addr = IndividualAddress(0)

    with raises(TypeError):
        frame.calculated_length()

    with raises(TypeError):
        frame.to_knx()
Exemplo n.º 3
0
def test_valid_tpci_control():
    """Test for valid tpci control."""
    raw = bytes((0x29, 0, 0, 0, 0, 0, 0, 0, 0, 0x80))
    frame = CEMIFrame()
    packet_len = frame.from_knx(raw)
    assert frame.code == CEMIMessageCode.L_DATA_IND
    assert frame.flags == 0
    assert frame.payload is None
    assert frame.src_addr == IndividualAddress(0)
    assert frame.dst_addr == IndividualAddress(0)
    assert frame.tpci == TConnect()
    assert packet_len == 10
    assert frame.calculated_length() == 10
    assert frame.to_knx() == raw
Exemplo n.º 4
0
def test_valid_command():
    """Test for valid frame parsing."""
    raw = get_data(0x29, 0, 0x0080, 0, 0, 1, 0, [])
    frame = CEMIFrame()
    packet_len = frame.from_knx(raw)
    assert frame.code == CEMIMessageCode.L_DATA_IND
    assert frame.flags == 0x0080
    assert frame.src_addr == IndividualAddress(0)
    assert frame.dst_addr == GroupAddress(0)
    assert frame.payload == GroupValueRead()
    assert frame.tpci == TDataGroup()
    assert packet_len == 11
    assert frame.calculated_length() == 11
    assert frame.to_knx() == raw