示例#1
0
def test_rx_selftodigi_downlink():
    """
    Test the digipeater module digipeats when own call is first.
    """
    interface = DummyAPRSInterface()
    digipeater = APRSDigipeater()
    digipeater.connect(interface)
    interface.received_msg.emit(
        interface=interface,
        frame=AX25UnnumberedInformationFrame(
            destination='VK4MSL-1',
            source='VK4MSL-2',
            repeaters=[
                'VK2RXX',  # Ordinarily, this should have the H bit set!
                'VK4RZA*',
                'VK4MSL-10',
                'VK4RZB'
            ],
            pid=0xff,
            payload=b'testing'))

    # This should have been digipeated
    eq_(len(interface.transmitted), 1)
    frame = interface.transmitted.pop()

    # It should be passed through VK4MSL-10.  H bits of prior repeaters
    # should be left intact.
    eq_(str(frame.header.repeaters), 'VK2RXX,VK4RZA*,VK4MSL-10*,VK4RZB')
示例#2
0
def test_connect_noadd():
    """
    Test we can connect an interface without adding its call to our
    "mydigi" list.
    """
    interface = DummyAPRSInterface()
    digipeater = APRSDigipeater()
    digipeater.connect(interface, addcall=False)
    eq_(digipeater._mydigi, set())
示例#3
0
def test_mydigi_replace():
    """
    Test we can replace the digipeater call list.
    """
    digipeater = APRSDigipeater()
    digipeater._mydigi.add(AX25Address.decode('VK4MSL'))
    digipeater.mydigi = ['VK4BWI']

    eq_(digipeater.mydigi, set([AX25Address.decode('VK4BWI')]))
示例#4
0
def test_rx_irrelevant():
    """
    Test the digipeater module ignores irrelevant frames.
    """
    interface = DummyAPRSInterface()
    digipeater = APRSDigipeater()
    digipeater.connect(interface)
    interface.received_msg.emit(interface=interface,
                                frame=AX25UnnumberedInformationFrame(
                                    destination='VK4MSL-1',
                                    source='VK4MSL-2',
                                    repeaters=['VK4RZA', 'VK4RZB'],
                                    pid=0xff,
                                    payload=b'testing'))

    # This should have been dropped
    eq_(len(interface.transmitted), 0)
示例#5
0
def test_rx_hybridpath():
    """
    Test the digipeater module handles typical APRS paths.
    """
    interface = DummyAPRSInterface()
    digipeater = APRSDigipeater()
    digipeater.connect(interface)
    interface.received_msg.emit(interface=interface,
                                frame=AX25UnnumberedInformationFrame(
                                    destination='VK4MSL-1',
                                    source='VK4MSL-2',
                                    repeaters=['WIDE1-1', 'WIDE2-2'],
                                    pid=0xff,
                                    payload=b'testing'))

    # This should have been digipeated
    eq_(len(interface.transmitted), 1)
    frame = interface.transmitted.pop()
    eq_(str(frame.header.repeaters), 'VK4MSL-10*,WIDE2-2')
示例#6
0
def test_rx_nexthop():
    """
    Test the digipeater module appends the correct WIDEn-N next hop.
    """
    interface = DummyAPRSInterface()
    digipeater = APRSDigipeater()
    digipeater.connect(interface)
    interface.received_msg.emit(interface=interface,
                                frame=AX25UnnumberedInformationFrame(
                                    destination='VK4MSL-1',
                                    source='VK4MSL-2',
                                    repeaters=['WIDE3-3'],
                                    pid=0xff,
                                    payload=b'testing'))

    # This should have been digipeated
    eq_(len(interface.transmitted), 1)
    frame = interface.transmitted.pop()
    eq_(str(frame.header.repeaters), 'VK4MSL-10*,WIDE3-2')
示例#7
0
def test_mydigi_read():
    """
    Test we can obtain a copy of the digipeater call list.
    """
    digipeater = APRSDigipeater()
    digipeater._mydigi.add(AX25Address.decode('VK4MSL'))
    mydigi = digipeater.mydigi

    assert mydigi is not digipeater._mydigi
    eq_(mydigi, digipeater._mydigi)
示例#8
0
def test_disconnect():
    """
    Test the digipeater module stops digipeating when disconnected.
    """
    interface = DummyAPRSInterface()
    digipeater = APRSDigipeater()
    digipeater.connect(interface)
    interface.received_msg.emit(interface=interface,
                                frame=AX25UnnumberedInformationFrame(
                                    destination='VK4MSL-1',
                                    source='VK4MSL-2',
                                    repeaters=['VK4MSL-10', 'VK4RZB'],
                                    pid=0xff,
                                    payload=b'testing'))

    # This should have been digipeated
    eq_(len(interface.transmitted), 1)
    frame = interface.transmitted.pop()

    # It should be passed through VK4MSL-10.
    eq_(str(frame.header.repeaters), 'VK4MSL-10*,VK4RZB')

    # Disconnect, then send another message
    digipeater.disconnect(interface)
    interface.received_msg.emit(interface=interface,
                                frame=AX25UnnumberedInformationFrame(
                                    destination='VK4MSL-1',
                                    source='VK4MSL-2',
                                    repeaters=['VK4MSL-10', 'VK4RZB'],
                                    pid=0xff,
                                    payload=b'testing 2'))

    # This should not have been digipeated
    eq_(len(interface.transmitted), 0)
示例#9
0
def test_rx_selftodigi_alias():
    """
    Test the digipeater module digipeats when alias is first.
    """
    interface = DummyAPRSInterface()
    digipeater = APRSDigipeater()
    digipeater.addaliases('GATE')
    digipeater.connect(interface)
    interface.received_msg.emit(
        interface=interface,
        frame=AX25UnnumberedInformationFrame(
            destination='VK4MSL-1',
            source='VK4MSL-2',
            repeaters=[
                'GATE',
                'VK4RZB'
            ],
            pid=0xff, payload=b'testing'
        )
    )

    # This should have been digipeated
    eq_(len(interface.transmitted), 1)
    frame = interface.transmitted.pop()

    # It should be passed through VK4MSL-10.
    eq_(str(frame.header.repeaters), 'VK4MSL-10*,VK4RZB')
示例#10
0
def test_disconnect_norm():
    """
    Test we can disconnect an interface without removing its call from our
    "mydigi" list.
    """
    interface = DummyAPRSInterface()
    digipeater = APRSDigipeater()
    digipeater.connect(interface)
    digipeater.disconnect(interface, rmcall=False)
    eq_(digipeater._mydigi, set([AX25Address.decode('VK4MSL-10')]))