diff options
| author | Dave Hibberd <hibby@debian.org> | 2024-02-24 13:47:31 +0000 |
|---|---|---|
| committer | Dave Hibberd <hibby@debian.org> | 2024-02-24 13:47:31 +0000 |
| commit | 22d82ba3c0d6bd591c135290d88adcc2414ba588 (patch) | |
| tree | 98dacd9f46560513d2869207b7f13a8ca9294ba2 /tests | |
| parent | e5819ceb55106d4b9b8d34d4d4e031b2a895b760 (diff) | |
| parent | fc438e6a84402e621877f6c30097442af46f122b (diff) | |
Update upstream source from tag 'upstream/20240224'
Update to upstream version '20240224'
with Debian dir f7af8ad341f9d73e94489b1e0a1b6e721fc7f61d
Diffstat (limited to 'tests')
28 files changed, 185 insertions, 10 deletions
diff --git a/tests/Python3_Driver_Testing.md b/tests/Python3_Driver_Testing.md index 7002a10..a7864a1 100644 --- a/tests/Python3_Driver_Testing.md +++ b/tests/Python3_Driver_Testing.md @@ -62,6 +62,7 @@ | <a name="Baofeng_F-11"></a> Baofeng_F-11 | [Implied by Baofeng_UV-5R](#user-content-Baofeng_UV-5R) | 18-Nov-2022 | Yes | 0.12% | | <a name="Baofeng_GT-3WP"></a> Baofeng_GT-3WP | [@KC9HI](https://github.com/KC9HI) | 3-Dec-2022 | Yes | 0.43% | | <a name="Baofeng_GT-5R"></a> Baofeng_GT-5R | [@KC9HI](https://github.com/KC9HI) | 18-Nov-2022 | Yes | 0.68% | +| <a name="Baofeng_UV-13Pro"></a> Baofeng_UV-13Pro | [@vdwel](https://github.com/vdwel) | 21-Feb-2024 | Yes | | | <a name="Baofeng_UV-17"></a> Baofeng_UV-17 | [@vdwel](https://github.com/vdwel) | 27-Nov-2023 | Yes | | | <a name="Baofeng_UV-17Pro"></a> Baofeng_UV-17Pro | [@vdwel](https://github.com/vdwel) | 27-Nov-2023 | Yes | | | <a name="Baofeng_UV-17ProGPS"></a> Baofeng_UV-17ProGPS | [@vdwel](https://github.com/vdwel) | 27-Nov-2023 | Yes | | @@ -79,7 +80,7 @@ | <a name="Baofeng_W31E"></a> Baofeng_W31E | [@KC9HI](https://github.com/KC9HI) | 14-Aug-2023 | Yes | | | <a name="Baojie_BJ-218"></a> Baojie_BJ-218 | [Implied by LUITON_LT-725UV](#user-content-LUITON_LT-725UV) | 16-Feb-2023 | Yes | 0.29% | | <a name="Baojie_BJ-318"></a> Baojie_BJ-318 | [@KC9HI](https://github.com/KC9HI) | 2-Jan-2023 | Yes | 0.10% | -| <a name="Baojie_BJ-9900"></a> Baojie_BJ-9900 | | | | 0.02% | +| <a name="Baojie_BJ-9900"></a> Baojie_BJ-9900 | | | Yes | 0.02% | | <a name="Baojie_BJ-UV55"></a> Baojie_BJ-UV55 | | | Yes | 0.03% | | <a name="Boblov_X3Plus"></a> Boblov_X3Plus | | | | 0.02% | | <a name="Boristone_8RS"></a> Boristone_8RS | [Implied by Radtel_RT-490](#user-content-Radtel_RT-490) | 11-Nov-2023 | Yes | 0.00% | @@ -153,6 +154,7 @@ | <a name="Kenwood_TH-D72_live_mode"></a> Kenwood_TH-D72_live_mode | [@kk7ds](https://github.com/kk7ds) | 21-Oct-2022 | Yes | 0.00% | | <a name="Kenwood_TH-D74_clone_mode"></a> Kenwood_TH-D74_clone_mode | [@kk7ds](https://github.com/kk7ds) | 30-Nov-2022 | Yes | 0.00% | | <a name="Kenwood_TH-D74_live_mode"></a> Kenwood_TH-D74_live_mode | [@kk7ds](https://github.com/kk7ds) | 20-Oct-2022 | Yes | 0.00% | +| <a name="Kenwood_TH-D75"></a> Kenwood_TH-D75 | [Reported working](https://chirp.danplanet.com/issues/11122) | 114-Feb-2024 | Yes | | | <a name="Kenwood_TH-D7G"></a> Kenwood_TH-D7G | [Probably works](https://github.com/kk7ds/chirp/blob/py3/chirp/drivers/kenwood_live.py) | 12-Dec-2022 | Yes | 0.00% | | <a name="Kenwood_TH-F6"></a> Kenwood_TH-F6 | [@KC9HI](https://github.com/KC9HI) | 30-Nov-2022 | Yes | 0.03% | | <a name="Kenwood_TH-F7"></a> Kenwood_TH-F7 | [@sv1](https://github.com/sv1) | 19-Oct-2022 | Yes | 0.03% | @@ -230,8 +232,11 @@ | <a name="LUITON_LT-588UV"></a> LUITON_LT-588UV | [@KC9HI](https://github.com/KC9HI) | 11-Nov-2022 | Yes | 0.01% | | <a name="LUITON_LT-725UV"></a> LUITON_LT-725UV | [@KC9HI](https://github.com/KC9HI) | 11-Dec-2022 | Yes | 0.02% | | <a name="Lanchonlh_HG-UV98"></a> Lanchonlh_HG-UV98 | | | Yes | 0.00% | -| <a name="Leixen_VV-898"></a> Leixen_VV-898 | [Implied by Jetstream_JT270MH](#user-content-Jetstream_JT270MH) | 13-Dec-2022 | Yes | 0.18% | -| <a name="Leixen_VV-898S"></a> Leixen_VV-898S | [@READ10](https://github.com/READ10) | 19-Dec-2022 | Yes | 0.10% | +| <a name="Leixen_VV-898"></a> Leixen_VV-898 | [Implied by Jetstream_JT270MH](#user-content-Jetstream_JT270MH) | 13-Dec-2022 | Yes | 0.16% | +| <a name="Leixen_VV-898E"></a> Leixen_VV-898E | | | Yes | 0.02% | +| <a name="Leixen_VV-898E_Dual_Bank"></a> Leixen_VV-898E_Dual_Bank | [Implied by Leixen_VV-898S_Dual_Bank](#user-content-Leixen_VV-898S_Dual_Bank) | 10-Feb-2024 | Yes | | +| <a name="Leixen_VV-898S"></a> Leixen_VV-898S | [@READ10](https://github.com/READ10) | 19-Dec-2022 | Yes | 0.08% | +| <a name="Leixen_VV-898S_Dual_Bank"></a> Leixen_VV-898S_Dual_Bank | [Reported working](https://chirp.danplanet.com/issues/4069) | 10-Feb-2024 | Yes | | | <a name="MMLradio_JC-8629"></a> MMLradio_JC-8629 | [@KC9HI](https://github.com/KC9HI) | 11-Nov-2023 | Yes | 0.01% | | <a name="MTC_UV-5R-3"></a> MTC_UV-5R-3 | [Implied by BTECH_UV-5X3](#user-content-BTECH_UV-5X3) | 9-Dec-2022 | Yes | 0.02% | | <a name="Maverick_RA-100"></a> Maverick_RA-100 | [@cetinajero](https://github.com/cetinajero) | 7-Jul-2023 | Yes | | @@ -255,6 +260,7 @@ | <a name="QYT_KT980PLUS"></a> QYT_KT980PLUS | [Implied by BTECH_UV-25X2](#user-content-BTECH_UV-25X2) | 11-Nov-2022 | Yes | 0.09% | | <a name="Quansheng_TG-UV2+"></a> Quansheng_TG-UV2+ | [Reported working](https://chirp.danplanet.com/issues/10398) | 26-Feb-2023 | Yes | 0.05% | | <a name="Quansheng_UV-K5"></a> Quansheng_UV-K5 | [@sq5bpf](https://github.com/sq5bpf) | 29-May-2023 | Yes | | +| <a name="Quansheng_UV-K5_egzumer"></a> Quansheng_UV-K5_egzumer | [@egzumer](https://github.com/egzumer) | 23-Jan-2024 | Yes | | | <a name="RT_Systems_CSV"></a> RT_Systems_CSV | | | | | | <a name="Radioddity_DB25-G"></a> Radioddity_DB25-G | [@KC9HI](https://github.com/KC9HI) | 11-Nov-2022 | Yes | 0.17% | | <a name="Radioddity_GA-2S"></a> Radioddity_GA-2S | [@KC9HI](https://github.com/KC9HI) | 4-Dec-2022 | Yes | 0.19% | @@ -370,6 +376,7 @@ | <a name="TYT_TH9000_220"></a> TYT_TH9000_220 | [Implied by Retevis_RT9000D_220-260](#user-content-Retevis_RT9000D_220-260) | 8-Dec-2022 | Yes | 0.04% | | <a name="TYT_TH9000_440"></a> TYT_TH9000_440 | [Implied by Retevis_RT9000D_400-490](#user-content-Retevis_RT9000D_400-490) | 8-Dec-2022 | Yes | 0.04% | | <a name="Talkpod_A36plus"></a> Talkpod_A36plus | [@KC9HI](https://github.com/KC9HI) | 12-Jun-2023 | Yes | | +| <a name="Talkpod_A36plus_8w"></a> Talkpod_A36plus_8w | [@KC9HI](https://github.com/KC9HI) | 16-Feb-2024 | Yes | | | <a name="Vertex_Standard_FTL-1011"></a> Vertex_Standard_FTL-1011 | | | | 0.02% | | <a name="Vertex_Standard_FTL-2011"></a> Vertex_Standard_FTL-2011 | | | | 0.05% | | <a name="Vertex_Standard_FTL-7011"></a> Vertex_Standard_FTL-7011 | | | | 0.03% | @@ -445,11 +452,11 @@ | <a name="Zastone_ZT-X6"></a> Zastone_ZT-X6 | [Implied by Retevis_RT22](#user-content-Retevis_RT22) | 9-Dec-2022 | Yes | 0.11% | ## Stats -**Drivers:** 442 +**Drivers:** 449 -**Tested:** 88% (389/53) (93% of usage stats) +**Tested:** 87% (395/54) (93% of usage stats) -**Byte clean:** 90% (402/40) +**Byte clean:** 91% (410/39) ## Meaning of this testing diff --git a/tests/__pycache__/test_detect.cpython-310-pytest-7.1.3.pyc b/tests/__pycache__/test_detect.cpython-310-pytest-7.1.3.pyc Binary files differindex 76b5d2a..d6df127 100644 --- a/tests/__pycache__/test_detect.cpython-310-pytest-7.1.3.pyc +++ b/tests/__pycache__/test_detect.cpython-310-pytest-7.1.3.pyc diff --git a/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc b/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc Binary files differindex 1bcf167..963e1f1 100644 --- a/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc +++ b/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc diff --git a/tests/images/BTECH_UV-25X2.img b/tests/images/BTECH_UV-25X2.img Binary files differindex aec97d8..c9f47c1 100644 --- a/tests/images/BTECH_UV-25X2.img +++ b/tests/images/BTECH_UV-25X2.img diff --git a/tests/images/BTECH_UV-50X2.img b/tests/images/BTECH_UV-50X2.img Binary files differindex 6bac4fb..d772c74 100644 --- a/tests/images/BTECH_UV-50X2.img +++ b/tests/images/BTECH_UV-50X2.img diff --git a/tests/images/BTECH_UV-5X3.img b/tests/images/BTECH_UV-5X3.img Binary files differindex aa6ad8a..7c1bc11 100644 --- a/tests/images/BTECH_UV-5X3.img +++ b/tests/images/BTECH_UV-5X3.img diff --git a/tests/images/Baofeng_5RM.img b/tests/images/Baofeng_5RM.img Binary files differindex 8cff8e8..a8fe738 100644 --- a/tests/images/Baofeng_5RM.img +++ b/tests/images/Baofeng_5RM.img diff --git a/tests/images/Baofeng_UV-13Pro.img b/tests/images/Baofeng_UV-13Pro.img Binary files differnew file mode 100644 index 0000000..2382e67 --- /dev/null +++ b/tests/images/Baofeng_UV-13Pro.img diff --git a/tests/images/Kenwood_TH-D75.img b/tests/images/Kenwood_TH-D75.img Binary files differnew file mode 100644 index 0000000..39a7c28 --- /dev/null +++ b/tests/images/Kenwood_TH-D75.img diff --git a/tests/images/Leixen_VV-898S.img b/tests/images/Leixen_VV-898S.img Binary files differindex 10a264a..9196ebc 100644 --- a/tests/images/Leixen_VV-898S.img +++ b/tests/images/Leixen_VV-898S.img diff --git a/tests/images/Quansheng_UV-K5.img b/tests/images/Quansheng_UV-K5.img Binary files differindex 4bdae31..8c7e36e 100644 --- a/tests/images/Quansheng_UV-K5.img +++ b/tests/images/Quansheng_UV-K5.img diff --git a/tests/images/Quansheng_UV-K5_egzumer.img b/tests/images/Quansheng_UV-K5_egzumer.img Binary files differnew file mode 100644 index 0000000..cf67ba4 --- /dev/null +++ b/tests/images/Quansheng_UV-K5_egzumer.img diff --git a/tests/images/Retevis_RA79.img b/tests/images/Retevis_RA79.img Binary files differindex 41cc21a..0ca8019 100644 --- a/tests/images/Retevis_RA79.img +++ b/tests/images/Retevis_RA79.img diff --git a/tests/images/Talkpod_A36plus_8w.img b/tests/images/Talkpod_A36plus_8w.img Binary files differnew file mode 100644 index 0000000..166d9a5 --- /dev/null +++ b/tests/images/Talkpod_A36plus_8w.img diff --git a/tests/py3_driver_testers.txt b/tests/py3_driver_testers.txt index 59f2bb9..d4a1d05 100644 --- a/tests/py3_driver_testers.txt +++ b/tests/py3_driver_testers.txt @@ -77,6 +77,7 @@ Baofeng_UV-82HP,@KC9HI,18-Nov-2022 Baofeng_UV-82WP,@KC9HI,3-Dec-2022 Baofeng_UV-9G,@KC9HI,3-Dec-2022 Baofeng_UV-9R,@KC9HI,3-Dec-2022 +Baofeng_UV-13Pro,@vdwel,21-Feb-2024 Baofeng_UV-17,@vdwel,27-Nov-2023 Baofeng_UV-17Pro,@vdwel,27-Nov-2023 Baofeng_UV-17ProGPS,@vdwel,27-Nov-2023 @@ -144,6 +145,7 @@ Kenwood_TH-D72_clone_mode,@kk7ds,28-Nov-2022 Kenwood_TH-D72_live_mode,@kk7ds,21-Oct-2022 Kenwood_TH-D74_clone_mode,@kk7ds,30-Nov-2022 Kenwood_TH-D74_live_mode,@kk7ds,20-Oct-2022 +Kenwood_TH-D75,#11122,114-Feb-2024 Kenwood_TH-F6,@KC9HI,30-Nov-2022 Kenwood_TH-F7,@sv1,19-Oct-2022 Kenwood_TH-G71,*kenwood_live,12-Dec-2022 @@ -201,6 +203,8 @@ Kenwood_TK-868,+Kenwood_TK-760,5-Dec-2022 Kenwood_TS-2000,ZS6CRW,10-Jan-2022 Leixen_VV-898,+Jetstream_JT270MH,13-Dec-2022 Leixen_VV-898S,@READ10,19-Dec-2022 +Leixen_VV-898S_Dual_Bank,#4069,10-Feb-2024 +Leixen_VV-898E_Dual_Bank,+Leixen_VV-898S_Dual_Bank,10-Feb-2024 LUITON_LT-316,+Retevis_RT22,9-Dec-2022 LUITON_LT-580_UHF,@KC9HI,8-Dec-2022 LUITON_LT-580_VHF,@KC9HI,8-Dec-2022 @@ -218,6 +222,7 @@ Q-MAC_HF-90_v300_or_earlier,@fthain,9-Mar-2023 Q-MAC_HF-90_v301_or_later,@fthain,9-Mar-2023 Quansheng_TG-UV2+,#10398,26-Feb-2023 Quansheng_UV-K5,@sq5bpf,29-May-2023 +Quansheng_UV-K5_egzumer,@egzumer,23-Jan-2024 QYT_KT-8R,@KC9HI,11-Nov-2022 QYT_KT-UV980,+WACCOM_MINI-8900,11-Nov-2022 QYT_KT-WP12,+Anysecu_WP-9900,11-Nov-2022 @@ -315,6 +320,7 @@ SenhaiX_8800,+Radioddity_GS-5B,17-Mar-2023 Socotran_FB-8629,+Radtel_RT-490,11-Nov-2023 Socotran_JC-8629,+Radtel_RT-490,11-Nov-2023 Talkpod_A36plus,@KC9HI,12-Jun-2023 +Talkpod_A36plus_8w,@KC9HI,16-Feb-2024 TDXone_TD-Q8A,@KC9HI,18-Dec-2022 TIDRADIO_TD-H6,@kk7ds,21-Oct-2022 TIDRADIO_TD-H8,@Sandmann34,7-Feb-2023 diff --git a/tests/test_brute_force.py b/tests/test_brute_force.py index 0ab09f7..eb5ea9b 100644 --- a/tests/test_brute_force.py +++ b/tests/test_brute_force.py @@ -91,8 +91,7 @@ class TestCaseBruteForce(base.DriverTest): if 'duplex' in m.immutable: self.skipTest('Test memory has immutable duplex') for duplex in self.rf.valid_duplexes: - if duplex not in ["", "-", "+", "split"]: - continue + assert duplex in ["", "-", "+", "split", "off"] if duplex == 'split': self.assertTrue(self.rf.can_odd_split, 'Radio supports split but does not set ' diff --git a/tests/test_detect.py b/tests/test_detect.py index 5a94cb9..8acad47 100644 --- a/tests/test_detect.py +++ b/tests/test_detect.py @@ -5,12 +5,17 @@ from unittest import mock import pytest from chirp import directory +from chirp import logger from tests import base class TestCaseDetect(base.DriverTest): def test_detect(self): - radio = directory.get_radio_by_image(self.TEST_IMAGE) + with logger.log_history(logging.WARNING, 'chirp.drivers') as history: + radio = directory.get_radio_by_image(self.TEST_IMAGE) + self.assertEqual([], history.get_history(), + 'Drivers should not log warnings/errors for ' + 'good images') if hasattr(radio, '_orig_rclass'): radio = radio._orig_rclass(self.TEST_IMAGE) if isinstance(self.radio, radio.__class__): diff --git a/tests/test_edges.py b/tests/test_edges.py index 2280819..a186e18 100644 --- a/tests/test_edges.py +++ b/tests/test_edges.py @@ -187,3 +187,10 @@ class TestBitwiseStrict(base.DriverTest): side_effect=_raise) def test_bitwise_unnecessary_seek(self, mock_assert): super().setUp() + + @pytest.mark.xfail(strict=False) + @mock.patch.object(bitwise.LOG, 'error') + def test_bitwise_errors(self, mock_log): + super().setUp() + self.assertFalse(mock_log.called, + [x[0][0] for x in mock_log.call_args_list]) diff --git a/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc Binary files differindex 398ad6b..3efe7a5 100644 --- a/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc +++ b/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc diff --git a/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc Binary files differindex 3334195..b47cb93 100644 --- a/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc +++ b/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc diff --git a/tests/unit/__pycache__/test_csv.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_csv.cpython-310-pytest-7.1.3.pyc Binary files differindex b086c48..ef21a8e 100644 --- a/tests/unit/__pycache__/test_csv.cpython-310-pytest-7.1.3.pyc +++ b/tests/unit/__pycache__/test_csv.cpython-310-pytest-7.1.3.pyc diff --git a/tests/unit/__pycache__/test_logger.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_logger.cpython-310-pytest-7.1.3.pyc Binary files differnew file mode 100644 index 0000000..b87c99b --- /dev/null +++ b/tests/unit/__pycache__/test_logger.cpython-310-pytest-7.1.3.pyc diff --git a/tests/unit/__pycache__/test_settings.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_settings.cpython-310-pytest-7.1.3.pyc Binary files differindex fad2d83..09c95b4 100644 --- a/tests/unit/__pycache__/test_settings.cpython-310-pytest-7.1.3.pyc +++ b/tests/unit/__pycache__/test_settings.cpython-310-pytest-7.1.3.pyc diff --git a/tests/unit/test_bitwise.py b/tests/unit/test_bitwise.py index f150886..9f40dcc 100644 --- a/tests/unit/test_bitwise.py +++ b/tests/unit/test_bitwise.py @@ -16,6 +16,7 @@ from builtins import bytes import unittest +from unittest import mock import six @@ -97,6 +98,26 @@ class TestBitwiseBaseIntTypes(BaseTest): obj.foo[i] = i * 2 self.assertEqual(b'\x00\x02\x04\x06', data.get_packed()) + def test_int_array_set_raw(self): + data = memmap.MemoryMapBytes(bytes(b'\x00\x01\x02\x03')) + obj = bitwise.parse('u8 foo[4];', data) + obj.foo.set_raw(b'\x09\x08\x07\x06') + self.assertEqual(9, obj.foo[0]) + self.assertEqual(8, obj.foo[1]) + self.assertEqual(7, obj.foo[2]) + self.assertEqual(6, obj.foo[3]) + + obj = bitwise.parse('u16 foo[2];', data) + obj.foo.set_raw(b'\x00\x01\x00\x02') + self.assertEqual(1, obj.foo[0]) + self.assertEqual(2, obj.foo[1]) + + with self.assertRaises(AssertionError): + obj.foo.set_raw(b'123') + + with self.assertRaises(AssertionError): + obj.foo.set_raw(b'12345') + class TestBitfieldTypes(BaseTest): def test_bitfield_u8(self): @@ -302,6 +323,42 @@ class TestBitwiseStructTypes(BaseTest): obj.set_raw('2') self.assertEqual(b'2', data.get_packed()) + @mock.patch.object(bitwise.LOG, 'error') + def test_struct_duplicate(self, mock_log): + bitwise.parse('struct\n{ u8 foo; u8 foo1:2, foo:4, foo3:2;} bar;', + memmap.MemoryMapBytes(b'\x00' * 128)) + bitwise.parse('struct\n{ u8 foo; u8 foo;} bar;', + memmap.MemoryMapBytes(b'\x00' * 128)) + bitwise.parse('struct\n{ u8 foo; u8 foo[2];} bar;', + memmap.MemoryMapBytes(b'\x00' * 128)) + self.assertEqual(3, mock_log.call_count) + + def test_struct_fill_raw(self): + data = memmap.MemoryMapBytes(bytes(b"...")) + defn = "struct { u8 bar; u16 baz; } foo;" + obj = bitwise.parse(defn, data) + obj.fill_raw(b'\xAA') + self.assertEqual(0xAA, obj.foo.bar) + self.assertEqual(0xAAAA, obj.foo.baz) + obj.foo.fill_raw(b'\xBB') + self.assertEqual(0xBB, obj.foo.bar) + self.assertEqual(0xBBBB, obj.foo.baz) + obj.foo.bar.fill_raw(b'\xCC') + self.assertEqual(0xCC, obj.foo.bar) + self.assertEqual(0xBBBB, obj.foo.baz) + + self.assertRaises(AssertionError, obj.fill_raw, '1') + self.assertRaises(AssertionError, obj.fill_raw, b'AB') + self.assertRaises(AssertionError, obj.fill_raw, False) + + +class TestBitwisePrintoffset(BaseTest): + @mock.patch.object(bitwise.LOG, 'debug') + def test_printoffset(self, mock_log): + defn = 'u8 foo; u16 bar; #printoffset "bar";' + bitwise.parse(defn, b"abcdZ") + mock_log.assert_called_once_with('bar: 3 (0x00000003)') + class TestBitwiseSeek(BaseTest): def test_seekto(self): @@ -339,3 +396,23 @@ class TestBitwiseStringEncoders(BaseTest): def test_decode_bytes(self): self.assertEqual('foobar\x00', bitwise.string_straight_decode(b'foobar\x00')) + + +class TestPath(BaseTest): + def test_get_path(self): + fmt = ("u8 foo;" + "u8 bar[2];" + "struct {" + " u8 foo;" + " u8 bar[2];" + " u8 baz1:4," + " baz2:4;" + " struct {" + " u16 childitem;" + " } child;" + "} structure[2];") + obj = bitwise.parse(fmt, memmap.MemoryMapBytes(b'\x00' * 128)) + obj.structure[0].bar[1] = 123 + obj.structure[1].child.childitem = 456 + self.assertEqual(123, obj.get_path('.structure[0].bar[1]')) + self.assertEqual(456, obj.get_path('structure[1].child.childitem')) diff --git a/tests/unit/test_chirp_common.py b/tests/unit/test_chirp_common.py index fb880c9..d0f22f9 100644 --- a/tests/unit/test_chirp_common.py +++ b/tests/unit/test_chirp_common.py @@ -762,7 +762,9 @@ class TestOverrideRules(base.BaseTest): 'BTECH_GMRS-V2', 'BTECH_MURS-V2', 'Radioddity_DB25-G', - 'Retevis_RB17P' + 'Retevis_RB17P', + 'Baofeng_UV-17ProGPS', + 'Baofeng_5RM', ] def _test_radio_override_immutable_policy(self, rclass): diff --git a/tests/unit/test_csv.py b/tests/unit/test_csv.py index 68bbcb9..c8428b0 100644 --- a/tests/unit/test_csv.py +++ b/tests/unit/test_csv.py @@ -72,6 +72,24 @@ class TestCSV(unittest.TestCase): self.assertEqual('5.0W', str(mem.power)) self.assertIn('UHF calling', mem.comment) + def test_csv_with_comments(self): + lines = list(CHIRP_CSV_MODERN.strip().split('\n')) + lines.insert(0, '# This is a comment') + lines.insert(0, '# Test file with comments') + lines.insert(4, '# Test comment in the middle') + lines.append('# Comment at the end') + with open(self.testfn, 'w', newline='') as f: + f.write('\r\n'.join(lines)) + csv = generic_csv.CSVRadio(self.testfn) + mem = csv.get_memory(0) + self.assertEqual(146520000, mem.freq) + mem = csv.get_memory(1) + self.assertEqual(446000000, mem.freq) + csv.save(self.testfn) + with open(self.testfn, 'r') as f: + read_lines = [x.strip() for x in f.readlines()] + self.assertEqual(lines, read_lines) + def test_parse_modern_bom(self): self.test_parse_modern(output_encoding='utf-8-sig') diff --git a/tests/unit/test_logger.py b/tests/unit/test_logger.py new file mode 100644 index 0000000..e4c32a9 --- /dev/null +++ b/tests/unit/test_logger.py @@ -0,0 +1,38 @@ +import logging + +from chirp import logger +from tests.unit import base + + +class TestLogger(base.BaseTest): + def test_log_history(self): + drv_log = logging.getLogger('chirp.drivers.foo') + ui_log = logging.getLogger('chirp.wxui.foo') + root_log = logging.getLogger() + + root_log.setLevel(logging.DEBUG) + + def log_all(): + for log in (drv_log, ui_log, root_log): + log.debug('debug') + log.warning('warning') + log.error('error') + + # Log to everything + log_all() + + with logger.log_history(logging.WARNING, 'chirp.drivers') as h: + log_all() + history = h.get_history() + + # We should only have the error,warning messages from drivers + # since we started the capture, not before + self.assertEqual(2, len(history)) + + with logger.log_history(logging.WARNING, 'chirp.drivers') as h: + log_all() + history = h.get_history() + + # Make sure we only have the captured logs, not any leftover from + # the previous run + self.assertEqual(2, len(history)) diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py index 108fb16..3712847 100644 --- a/tests/unit/test_settings.py +++ b/tests/unit/test_settings.py @@ -30,24 +30,28 @@ class TestSettingValues(base.BaseTest): def test_radio_setting_value_integer(self): value = settings.RadioSettingValueInteger(0, 10, 5) + value.initialize() self.assertEqual(value.get_value(), 5) self._set_and_test(value, 1, 0, 10) self._set_and_catch(value, -1, 11) def test_radio_setting_value_float(self): value = settings.RadioSettingValueFloat(1.0, 10.5, 5.0) + value.initialize() self.assertEqual(value.get_value(), 5.0) self._set_and_test(value, 2.5, 1.0, 10.5) self._set_and_catch(value, 0.9, 10.6, -1.5) def test_radio_setting_value_boolean(self): value = settings.RadioSettingValueBoolean(True) + value.initialize() self.assertTrue(value.get_value()) self._set_and_test(value, True, False) def test_radio_setting_value_list(self): opts = ["Abc", "Def", "Ghi"] value = settings.RadioSettingValueList(opts, "Abc") + value.initialize() self.assertEqual(value.get_value(), "Abc") self.assertEqual(int(value), 0) self._set_and_test(value, "Def", "Ghi", "Abc") @@ -57,6 +61,7 @@ class TestSettingValues(base.BaseTest): def test_radio_setting_value_list_by_index(self): opts = ["Abc", "Def", "Ghi"] value = settings.RadioSettingValueList(opts, current_index=1) + value.initialize() self.assertEqual(value.get_value(), "Def") self.assertEqual(int(value), 1) self._set_and_test(value, "Def", "Ghi", "Abc") @@ -65,6 +70,7 @@ class TestSettingValues(base.BaseTest): # Make sure we int() the index, as we may pass a bitwise object value = settings.RadioSettingValueList(opts, current_index='1') + value.initialize() self.assertEqual(value.get_value(), "Def") value.set_index(0) @@ -78,6 +84,7 @@ class TestSettingValues(base.BaseTest): def test_radio_setting_value_string(self): value = settings.RadioSettingValueString(1, 5, "foo", autopad=False) + value.initialize() self.assertEqual(value.get_value(), "foo") self.assertEqual(str(value), "foo") self._set_and_test(value, "a", "abc", "abdef") @@ -88,6 +95,7 @@ class TestSettingValues(base.BaseTest): pass value = settings.RadioSettingValueString(0, 5, "foo", autopad=False) + value.initialize() def test_validate(val): if val == "bar": @@ -98,6 +106,7 @@ class TestSettingValues(base.BaseTest): def test_changed(self): value = settings.RadioSettingValueBoolean(False) + value.initialize() self.assertFalse(value.changed()) value.set_value(False) self.assertFalse(value.changed()) @@ -171,3 +180,10 @@ class TestSettingContainers(base.BaseTest): for c in settings.BANNED_NAME_CHARACTERS: self.assertRaises(settings.InvalidNameError, settings.RadioSetting, "foo%sbar" % c, "Foo") + + def test_setting_deferred(self): + val = settings.RadioSettingValueInteger(0, 10, 12) + rs = settings.RadioSetting('test', 'Test', val) + self.assertFalse(rs.value.initialized) + rs.value = 1 + self.assertTrue(rs.value.initialized) |
