Exemple #1
0
def test_decode_unknown_type():
    """
    Test the decode routine rejects frames it cannot recognise.
    """
    frame = AX25UnnumberedInformationFrame(destination='APZAIO',
                                           source='VK4MSL-7',
                                           pid=0xf0,
                                           payload=b'X A mystery frame X')
    decoded = APRSFrame.decode(frame, logging.getLogger('decoder'))
    assert_is(decoded, frame)
Exemple #2
0
def test_decode_message():
    """
    Test the decode routine can recognise a message frame.
    """
    frame = AX25UnnumberedInformationFrame(destination='APZAIO',
                                           source='VK4MSL-7',
                                           pid=0xf0,
                                           payload=b':VK4MDL-7 :Hi')
    decoded = APRSFrame.decode(frame, logging.getLogger('decoder'))
    assert_is_not(decoded, frame)
    assert isinstance(decoded, APRSMessageFrame)
Exemple #3
0
def test_decode_wrong_pid():
    """
    Test the decode routine ignores UI frames with wrong PID.
    """
    frame = AX25UnnumberedInformationFrame(
        destination='APZAIO',
        source='VK4MSL-7',
        pid=0x80,  # Not correct for APRS, should not get decoded.
        payload=b'Test frame that\'s not APRS')
    decoded = APRSFrame.decode(frame, logging.getLogger('decoder'))
    assert_is(decoded, frame)
Exemple #4
0
def test_decode_no_payload():
    """
    Test the decode routine rejects frames without a payload.
    """
    frame = AX25UnnumberedInformationFrame(
        destination='APZAIO',
        source='VK4MSL-7',
        pid=0xf0,
        payload=b''  # Empty payload
    )
    decoded = APRSFrame.decode(frame, logging.getLogger('decoder'))
    assert_is(decoded, frame)
Exemple #5
0
def test_decode_message_ack():
    """
    Test the decode routine can recognise a message acknowledgement frame.
    """
    frame = AX25UnnumberedInformationFrame(destination='APZAIO',
                                           source='VK4MSL-7',
                                           pid=0xf0,
                                           payload=b':VK4MDL-7 :ack2')
    decoded = APRSFrame.decode(frame, logging.getLogger('decoder'))
    assert_is_not(decoded, frame)
    assert isinstance(decoded, APRSMessageAckFrame)
    eq_(decoded.msgid, '2')
Exemple #6
0
def test_decode_message_replyack_reply():
    """
    Test the decode routine can recognise a message frame sent as a
    reply-ack.
    """
    frame = AX25UnnumberedInformationFrame(destination='APZAIO',
                                           source='VK4MSL-7',
                                           pid=0xf0,
                                           payload=b':VK4MDL-7 :Hi{01}45')
    decoded = APRSFrame.decode(frame, logging.getLogger('decoder'))
    assert_is_not(decoded, frame)
    assert isinstance(decoded, APRSMessageFrame)
    eq_(decoded.replyack, '45')
    eq_(decoded.msgid, '01')