diff options
| author | Yogeswaran Umasankar <kd8mbd@gmail.com> | 2024-01-20 20:25:00 +0000 |
|---|---|---|
| committer | Yogeswaran Umasankar <kd8mbd@gmail.com> | 2024-01-20 20:25:00 +0000 |
| commit | e5ac17f663e108f458b5e3d34bfcc85b2d0482bc (patch) | |
| tree | 13f52b05b717ade7f8ba982ee1d910834067c0c6 /tests/unit/test_wxui_radiothread.py | |
| parent | f5e142a4e54bfda24bec40e923c643b434948a04 (diff) | |
| parent | ac8027c43c9df4431092d633a06bd5bd92341247 (diff) | |
Update upstream source from tag 'upstream/1%20240117'
Update to upstream version '1:20240117'
with Debian dir 8d8fe4e002b178241b01b8f9b69615aa2480698f
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)]) |
