summaryrefslogtreecommitdiff
path: root/tests/unit/test_alinco_clone.py
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2026-10-31 12:31:32 +0000
committerDave Hibberd <hibby@debian.org>2026-10-31 12:31:32 +0000
commitef0af95bac2c3d310fe55f54853904395b57f884 (patch)
treeb8d8d0734308a9c9a1440a2755ce15b480de4bcb /tests/unit/test_alinco_clone.py
parent5f4fe8ab00a12060662e5df0fc8855f0488de35d (diff)
New upstream version 20261030upstream/20261030upstream
Diffstat (limited to 'tests/unit/test_alinco_clone.py')
-rw-r--r--tests/unit/test_alinco_clone.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/unit/test_alinco_clone.py b/tests/unit/test_alinco_clone.py
index c5e28ca..5aaf872 100644
--- a/tests/unit/test_alinco_clone.py
+++ b/tests/unit/test_alinco_clone.py
@@ -145,7 +145,9 @@ class AlincoCloneTest(unittest.TestCase):
radio = rclass(pipe)
radio.sync_in()
if not radio.NEEDS_COMPAT_SERIAL:
- self.assertIsInstance(radio._mmap, memmap.MemoryMapBytes)
+ # Note that MemoryMap (the str-based compat class) is a subclass
+ # of MemoryMapBytes, so this must compare the type exactly.
+ self.assertEqual(type(radio._mmap), memmap.MemoryMapBytes)
def _test_alinco_upload(self, rclass, image):
pipe = FakeAlincoSerial(image)
@@ -157,15 +159,42 @@ class AlincoCloneTest(unittest.TestCase):
self.assertEqual(ref_image[0x200:rclass._memsize],
pipe.image.get_packed()[0x200:rclass._memsize])
+ def _test_alinco_roundtrip(self, rclass, image):
+ # Read from the radio and then write the same thing straight back,
+ # which is what actually happens in the field (#12611)
+ pipe = FakeAlincoSerial(image)
+ radio = rclass(None)
+ radio.pipe = pipe
+ with mock.patch('time.sleep'):
+ radio.sync_in()
+ pipe.zero()
+ with mock.patch('time.sleep'):
+ radio.sync_out()
+ ref_image = open(image, 'rb').read()
+ self.assertEqual(ref_image[0x200:rclass._memsize],
+ pipe.image.get_packed()[0x200:rclass._memsize])
+
def _test_alinco(self, rclass):
ident = directory.radio_class_id(rclass)
image = os.path.join(os.path.dirname(__file__),
'..', 'images',
'%s.img' % ident)
with mock.patch('time.sleep'):
+ # The round-trip goes first, as it is the flow that actually
+ # broke in the field (#12611)
+ self._test_alinco_roundtrip(rclass, image)
self._test_alinco_upload(rclass, image)
self._test_alinco_download(rclass, image)
+ def _test_roundtrip(self, rclass):
+ """Run only the read-then-write-back test for @rclass"""
+ ident = directory.radio_class_id(rclass)
+ image = os.path.join(os.path.dirname(__file__),
+ '..', 'images',
+ '%s.img' % ident)
+ with mock.patch('time.sleep'):
+ self._test_alinco_roundtrip(rclass, image)
+
def test_djg7(self):
self._test_alinco(alinco.AlincoDJG7EG)
@@ -180,6 +209,17 @@ class AlincoCloneTest(unittest.TestCase):
# specifically
self._test_alinco(alinco.DJ175Radio)
+ def test_dj175_roundtrip(self):
+ # Uploading after a download used to fail with
+ # "encoding with 'hex' codec failed (TypeError: a bytes-like
+ # object is required, not 'str')" (#12611). This is kept as its
+ # own test so that the actual failure is reported, rather than
+ # tripping over the mmap type check in _test_alinco_download().
+ self._test_roundtrip(alinco.DJ175Radio)
+
+ def test_dr235_roundtrip(self):
+ self._test_roundtrip(alinco.DR235Radio)
+
def test_all_alinco_identify(self):
# Make sure all the alinco models have bytes for their _model
# and can identify properly