diff options
| author | Dave Hibberd <d@vehibberd.com> | 2024-01-23 00:30:05 +0000 |
|---|---|---|
| committer | Dave Hibberd <d@vehibberd.com> | 2024-01-23 00:30:05 +0000 |
| commit | 691b1b410562075e0d76033f5c8ddaf1da7344d0 (patch) | |
| tree | f183304481dc93719dec8c121cd1280822b2da4e /tests/unit/test_wxui_radiothread.py | |
| parent | aed54358fee5927f9b4913566d84b92255e08e12 (diff) | |
| parent | ac8027c43c9df4431092d633a06bd5bd92341247 (diff) | |
Merge branch 'upstream' into 'upstream'
New upstream version 1:20240117
See merge request debian-hamradio-team/chirp!5
Diffstat (limited to 'tests/unit/test_wxui_radiothread.py')
| -rw-r--r-- | tests/unit/test_wxui_radiothread.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/unit/test_wxui_radiothread.py b/tests/unit/test_wxui_radiothread.py index 99f9438..1088b81 100644 --- a/tests/unit/test_wxui_radiothread.py +++ b/tests/unit/test_wxui_radiothread.py @@ -3,10 +3,17 @@ import time from unittest import mock sys.modules['wx'] = wx = mock.MagicMock() +sys.modules['wx.lib'] = mock.MagicMock() +sys.modules['wx.lib.scrolledpanel'] = mock.MagicMock() +sys.modules['wx.lib.sized_controls'] = mock.MagicMock() +sys.modules['wx.richtext'] = mock.MagicMock() +wx.lib.newevent.NewCommandEvent.return_value = None, None +sys.modules['chirp.wxui.developer'] = mock.MagicMock() # These need to be imported after the above mock so that we don't require # wx to be present for these tests from tests.unit import base # noqa +from chirp.wxui import clone # noqa from chirp.wxui import radiothread # noqa @@ -105,3 +112,42 @@ class TestRadioThread(base.BaseTest): radio.set_memory.assert_not_called() radio.get_features.assert_not_called() wx.PostEvent.assert_not_called() + + +class TestClone(base.BaseTest): + @mock.patch('platform.system', return_value='Linux') + def test_sort_ports_unix(self, system): + ports = [ + mock.MagicMock(device='/dev/cu.zed', + description='My Zed'), + mock.MagicMock(device='/dev/cu.abc', + description='Some device'), + mock.MagicMock(device='/dev/cu.serial', + description='') + ] + self.assertEqual( + ['Some device (cu.abc)', + 'cu.serial', + 'My Zed (cu.zed)'], + [clone.port_label(p) + for p in sorted(ports, key=clone.port_sort_key)]) + + @mock.patch('platform.system', return_value='Windows') + def test_sort_ports_windows(self, system): + ports = [ + mock.MagicMock(device='COM7', + description='Some serial device'), + mock.MagicMock(device='COM17', + description='Some other device'), + mock.MagicMock(device='CNC0', + description='Some weird device'), + mock.MagicMock(device='COM4', + description=''), + ] + self.assertEqual( + ['CNC0: Some weird device', + 'COM4', + 'COM7: Some serial device', + 'COM17: Some other device'], + [clone.port_label(p) + for p in sorted(ports, key=clone.port_sort_key)]) |
