def test_decode_bytes_short(): """ Test decoding a truncated address does not crash. """ try: AX25Address.decode(from_hex('ac 96 68 9a a6')) assert False, 'This should not work' except ValueError as e: eq_(str(e), 'AX.25 addresses must be 7 bytes!')
def test_decode_str_invalid(): """ Test that strings are correctly validated. """ try: AX25Address.decode('VK4-MSL') assert False, 'Should not have worked' except ValueError as e: eq_(str(e), 'Not a valid SSID: VK4-MSL')
def test_decode_wrongtype(): """ Test that incorrect types are handled. """ try: AX25Address.decode(12345) assert False, 'Should not have worked' except TypeError as e: eq_(str(e), "Don't know how to decode 12345")
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')]))
def test_addresses(): """ Test given a list of AX25Addresses, AX25Path passes them in. """ path = AX25Path(AX25Address.decode('VK4MSL'), AX25Address.decode('VK4RZB'), AX25Address.decode('VK4RZA')) eq_(path._path[0]._callsign, 'VK4MSL') eq_(path._path[1]._callsign, 'VK4RZB') eq_(path._path[2]._callsign, 'VK4RZA')
def test_decode_ax25address(): """ Test that passing in a AX25Address results in a clone being made. """ addr1 = AX25Address('VK4MSL', 5) addr2 = AX25Address.decode(addr1) assert addr1 is not addr2 for field in ('_callsign', '_ssid', '_ch', \ '_res0', '_res1', '_extension'): eq_(getattr(addr1, field), getattr(addr2, field))
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)
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')]))
def __init__(self): self._loop = DummyLoop() self._retransmit_count = 2 self._retransmit_timeout_base = 5 self._retransmit_timeout_rand = 5 self._retransmit_timeout_scale = 1.5 self.mycall = AX25Address.decode('N0CALL') self._next_msgid = 12345 self.sent = [] self.finished = []
def test_msghandler_addressee(): """ Test the handler passes through the addressee given. """ calls = [] aprshandler = DummyAPRSHandler() msghandler = APRSMessageHandler(aprshandler=aprshandler, addressee='CQ', path=['WIDE1-1', 'WIDE2-1'], message='testing', replyack=False, log=logging.getLogger('messagehandler')) eq_(msghandler.addressee, AX25Address.decode('CQ'))
def test_decode_str(): """ Test that we can decode a call-sign into an AX.25 address. """ addr = AX25Address.decode('VK4MSL') eq_(addr._callsign, 'VK4MSL')
def __init__(self): self.received_msg = Signal() self.mycall = AX25Address.decode('VK4MSL-10') self.transmitted = []
def test_decode_str_ssid(): """ Test that we can decode the SSID in a string. """ addr = AX25Address.decode('VK4MSL-12') eq_(addr._ssid, 12)
def test_decode_bytes_ch(): """ Test we can decode the C/H bit in binary. """ addr = AX25Address.decode(from_hex('ac 96 68 9a a6 98 80')) eq_(addr._ch, True)
def test_decode_bytes_res1(): """ Test we can decode the first reserved bit in binary. """ addr = AX25Address.decode(from_hex('ac 96 68 9a a6 98 40')) eq_(addr._res1, True)
def test_decode_bytes_ssid(): """ Test we can decode the SSID in binary. """ addr = AX25Address.decode(from_hex('ac 96 68 9a a6 98 14')) eq_(addr._ssid, 10)
def test_decode_bytes_ext(): """ Test we can decode the extension bit set in binary. """ addr = AX25Address.decode(from_hex('ac 96 68 9a a6 98 01')) eq_(addr._extension, True)
def test_decode_bytes_spaces(): """ Test trailing spaces are truncated in call-signs. """ addr = AX25Address.decode(from_hex('ac 96 68 84 82 40 00')) eq_(addr._callsign, 'VK4BA')
def test_decode_str_ch(): """ Test that we can decode the C/H bit in a string. """ addr = AX25Address.decode('VK4MSL*') eq_(addr._ch, True)
def addressee(self): self.addressee_calls += 1 return AX25Address.decode('N0CALL')
def test_decode_bytes(): """ Test we can decode a plain AX.25 address in binary. """ addr = AX25Address.decode(from_hex('ac 96 68 9a a6 98 00')) eq_(addr._callsign, 'VK4MSL')