You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
802 B
25 lines
802 B
import unittest
|
|
|
|
from utils import bytes_3, bytes_4, get_alias, int_id
|
|
|
|
|
|
class FreeDmrUtilsTest(unittest.TestCase):
|
|
def test_integer_byte_helpers_are_big_endian(self):
|
|
self.assertEqual(bytes_3(0x010203), b"\x01\x02\x03")
|
|
self.assertEqual(bytes_4(0x01020304), b"\x01\x02\x03\x04")
|
|
self.assertEqual(int_id(b"\x01\x02\x03\x04"), 0x01020304)
|
|
|
|
def test_get_alias_returns_matching_record_or_original_id(self):
|
|
aliases = {
|
|
3120001: {"callsign": "M0ABC", "name": "Test"},
|
|
235: "TG235",
|
|
}
|
|
|
|
self.assertEqual(get_alias(bytes_3(3120001), aliases, "callsign"), ["M0ABC"])
|
|
self.assertEqual(get_alias(235, aliases), "TG235")
|
|
self.assertEqual(get_alias(999, aliases), 999)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|