コード例 #1
0
ファイル: test_message.py プロジェクト: tarpn/aioax25
def test_on_response_rej():
    """
    Test calling _on_response with REJ when in SEND triggers REJECT
    """
    aprshandler = DummyAPRSHandler()
    msghandler = APRSMessageHandler(aprshandler=aprshandler,
                                    addressee='CQ',
                                    path=['WIDE1-1', 'WIDE2-1'],
                                    message='testing',
                                    replyack=False,
                                    log=logging.getLogger('messagehandler'))

    # Force state, suppose we just sent our request.
    msghandler._state = msghandler.HandlerState.SEND

    # Pass in our frame
    frame = APRSMessageRejFrame(destination='APZAIO',
                                source='VK4MSL-9',
                                addressee='N0CALL',
                                msgid='123')
    msghandler._on_response(frame)

    # Our official response should be the frame we just received
    assert_is(msghandler.response, frame)

    # And we should be done
    eq_(msghandler.state, msghandler.HandlerState.REJECT)
コード例 #2
0
ファイル: test_message.py プロジェクト: tarpn/aioax25
def test_on_response_timedout():
    """
    Test calling _on_response when in TIMEOUT ignores message
    """
    aprshandler = DummyAPRSHandler()
    msghandler = APRSMessageHandler(aprshandler=aprshandler,
                                    addressee='CQ',
                                    path=['WIDE1-1', 'WIDE2-1'],
                                    message='testing',
                                    replyack=False,
                                    log=logging.getLogger('messagehandler'))

    # Force state, suppose we already received a reply, and a well-meaning
    # digi has repeated it.
    msghandler._state = msghandler.HandlerState.SUCCESS
    frame1 = APRSMessageAckFrame(destination='APZAIO',
                                 source='VK4MSL-9',
                                 addressee='N0CALL',
                                 msgid='123')
    msghandler._response = frame1

    frame2 = APRSMessageAckFrame(destination='APZAIO',
                                 source='VK4MSL-9',
                                 addressee='N0CALL',
                                 msgid='123')
    msghandler._on_response(frame2)

    # Our official response should be the first one
    assert_is(msghandler.response, frame1)
    assert_is_not(msghandler.response, frame2)