Пример #1
0
def test_invalid_src_addr():
    """Test for invalid src addr."""
    frame = CEMIFrame()
    frame.code = CEMIMessageCode.L_DATA_IND
    frame.flags = 0
    frame.payload = GroupValueRead()
    frame.src_addr = GroupAddress(0)
    frame.dst_addr = IndividualAddress(0)

    with pytest.raises(ConversionError, match=r"src_addr invalid"):
        frame.to_knx()
Пример #2
0
def test_invalid_dst_addr():
    """Test for invalid dst addr."""
    frame = CEMIFrame()
    frame.code = CEMIMessageCode.L_DATA_IND
    frame.flags = 0
    frame.mpdu_len = 1
    frame.payload = GroupValueRead()
    frame.src_addr = IndividualAddress(0)
    frame.dst_addr = None

    with raises(ConversionError, match=r"dst_addr not set"):
        frame.to_knx()
Пример #3
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()
Пример #4
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()