コード例 #1
0
def test_from_knx_with_not_handleable_cemi():
    """Test for having unhandlebale cemi set."""
    frame = CEMIFrame()
    with pytest.raises(
        UnsupportedCEMIMessage, match=r".*CEMIMessageCode not implemented:.*"
    ):
        frame.from_knx(get_data(0x30, 0, 0, 0, 0, 2, 0, []))
コード例 #2
0
ファイル: cemi_frame_test.py プロジェクト: onkelbeh/xknx
def test_from_knx_with_not_implemented_cemi():
    """Test for having not implemented CEMI set."""
    frame = CEMIFrame()
    with raises(UnsupportedCEMIMessage, match=r".*Could not handle CEMIMessageCode:.*"):
        frame.from_knx(
            get_data(CEMIMessageCode.L_BUSMON_IND.value, 0, 0, 0, 0, 2, 0, [])
        )
コード例 #3
0
ファイル: cemi_frame_test.py プロジェクト: onkelbeh/xknx
def test_valid_command():
    """Test for valid frame parsing."""
    frame = CEMIFrame()
    packet_len = frame.from_knx(get_data(0x29, 0, 0, 0, 0, 1, 0, []))
    assert frame.code == CEMIMessageCode.L_DATA_IND
    assert frame.flags == 0
    assert frame.mpdu_len == 1
    assert frame.payload == GroupValueRead()
    assert frame.src_addr == IndividualAddress(0)
    assert frame.dst_addr == IndividualAddress(0)
    assert packet_len == 11
コード例 #4
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
コード例 #5
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
コード例 #6
0
def test_invalid_apdu_len():
    """Test for invalid apdu len."""
    frame = CEMIFrame()
    with pytest.raises(CouldNotParseKNXIP, match=r".*APDU LEN should be .*"):
        frame.from_knx(get_data(0x29, 0, 0, 0, 0, 2, 0, []))
コード例 #7
0
def test_from_knx_individual_address():
    """Test conversion for a cemi with a individual address as destination."""
    frame = CEMIFrame()
    frame.from_knx(get_data(0x29, 0, 0x00, 0, 0, 1, 0, []))

    assert frame.dst_addr == IndividualAddress(0)
コード例 #8
0
def test_from_knx_group_address():
    """Test conversion for a cemi with a group address as destination."""
    frame = CEMIFrame()
    frame.from_knx(get_data(0x29, 0, 0x80, 0, 0, 1, 0, []))

    assert frame.dst_addr == GroupAddress(0)