summaryrefslogtreecommitdiff
path: root/tests/unit/test_cli.py
diff options
context:
space:
mode:
authorDave Hibberd <d@vehibberd.com>2023-10-16 21:37:34 +0100
committerDave Hibberd <d@vehibberd.com>2023-10-16 21:37:34 +0100
commit96e7558ee5db759a7214cd451a3478f3b44f59a3 (patch)
treee673aa5fb96256d43311c0e9581a2d5c6141ace6 /tests/unit/test_cli.py
parenta289d9178e89abd7dc0fb29bdd6dedf3987b4f06 (diff)
parent91dbf844ad923e3c4bca1252dd104d8fc8ce5475 (diff)
Update upstream source from tag 'upstream/20231016'
Update to upstream version '20231016' with Debian dir cd57b3fbc431f25a1408f045533dcb7f7b9975c0
Diffstat (limited to 'tests/unit/test_cli.py')
-rw-r--r--tests/unit/test_cli.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py
new file mode 100644
index 0000000..f08845b
--- /dev/null
+++ b/tests/unit/test_cli.py
@@ -0,0 +1,42 @@
+import os
+import unittest
+from unittest import mock
+
+from chirp.cli import main
+
+
+class TestCLI(unittest.TestCase):
+ def setUp(self):
+ self.stdout_lines = []
+ self.patches = []
+ self.patches.append(mock.patch('sys.exit'))
+ self.patches.append(mock.patch.object(main, 'print',
+ new=self.fake_print))
+ for patch in self.patches:
+ patch.start()
+
+ # A path to an image file we can pass to the CLI for testing
+ self.testfile = os.path.join(
+ os.path.abspath(
+ os.path.join(
+ os.path.dirname(__file__), '..', 'images',
+ 'Icom_IC-2820H.img')))
+
+ def tearDown(self):
+ for patch in self.patches:
+ patch.stop()
+
+ def fake_print(self, *a):
+ for i in a:
+ self.stdout_lines.append(str(i))
+
+ @property
+ def stdout(self):
+ return '\n'.join(self.stdout_lines)
+
+ def test_cli_simple(self):
+ # Super simple, just print the first memory and make sure it
+ # works
+ args = ['--mmap', self.testfile, '--get-mem', 0]
+ main.main(args=args)
+ self.assertIn('147.56', self.stdout)