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)
def test_message_ack_copy(): """ Test we can copy a message ACK frame """ msg = APRSMessageAckFrame(destination='APRS', source='VK4MSL', addressee='TEST', msgid=12345) msgcopy = msg.copy() assert msg is not msgcopy eq_(to_hex(bytes(msgcopy)), to_hex(bytes(msg)))
def test_on_response_ack(): """ Test calling _on_response with ACK when in SEND triggers SUCCESS """ 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 = APRSMessageAckFrame(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.SUCCESS)
def test_get_destination_msgframe(): """ Test _get_destination returns the addressee of a APRSMessageFrame. """ frame = APRSMessageAckFrame(destination='APZAIO', addressee='VK4BWI-2', source='VK4MSL-7', msgid='123') router = APRSRouter() destination = router._get_destination(frame) eq_(destination, frame.addressee)