示例#1
0
def test_telegram_individual_address():
    """Test telegram conversion flags with a individual address."""
    frame = CEMIFrame()
    frame.telegram = Telegram(destination_address=IndividualAddress(0))

    assert (
        frame.flags & CEMIFlags.DESTINATION_INDIVIDUAL_ADDRESS
    ) == CEMIFlags.DESTINATION_INDIVIDUAL_ADDRESS
示例#2
0
def test_telegram_group_address():
    """Test telegram conversion flags with a group address."""
    frame = CEMIFrame()
    frame.telegram = Telegram(destination_address=GroupAddress(0))

    assert (
        frame.flags & CEMIFlags.DESTINATION_GROUP_ADDRESS
    ) == CEMIFlags.DESTINATION_GROUP_ADDRESS
示例#3
0
def test_telegram_group_address():
    """Test telegram conversion flags with a group address."""
    frame = CEMIFrame()
    _telegram = Telegram(destination_address=GroupAddress(0))
    # test CEMIFrame.telegram setter
    frame.telegram = _telegram
    assert frame.flags & 0x0080 == CEMIFlags.DESTINATION_GROUP_ADDRESS
    assert frame.flags & 0x0C00 == CEMIFlags.PRIORITY_LOW
    # test CEMIFrame.telegram property
    assert frame.telegram == _telegram
示例#4
0
def test_telegram_individual_address():
    """Test telegram conversion flags with a individual address."""
    frame = CEMIFrame()
    _telegram = Telegram(destination_address=IndividualAddress(0), tpci=TConnect())
    # test CEMIFrame.telegram setter
    frame.telegram = _telegram
    assert frame.flags & 0x0080 == CEMIFlags.DESTINATION_INDIVIDUAL_ADDRESS
    assert frame.flags & 0x0C00 == CEMIFlags.PRIORITY_SYSTEM
    assert frame.flags & 0x0200 == CEMIFlags.NO_ACK_REQUESTED
    # test CEMIFrame.telegram property
    assert frame.telegram == _telegram
示例#5
0
def test_telegram_unsupported_address():
    """Test telegram conversion flags with an unsupported address."""
    frame = CEMIFrame()
    with pytest.raises(TypeError):
        frame.telegram = Telegram(destination_address=object())