summaryrefslogtreecommitdiff
path: root/tests/unit/test_chirp_common.py
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2026-08-20 23:11:02 +0100
committerDave Hibberd <hibby@debian.org>2026-08-20 23:11:02 +0100
commit5f4fe8ab00a12060662e5df0fc8855f0488de35d (patch)
tree95a7d9b81673c059b18a1e551079104050b4ca11 /tests/unit/test_chirp_common.py
parentdff1a610625ebe7841fca01e20ca6d86b65ee4d0 (diff)
New upstream version 20260814upstream/20260814
Diffstat (limited to 'tests/unit/test_chirp_common.py')
-rw-r--r--tests/unit/test_chirp_common.py85
1 files changed, 80 insertions, 5 deletions
diff --git a/tests/unit/test_chirp_common.py b/tests/unit/test_chirp_common.py
index 0edce51..4b7cda5 100644
--- a/tests/unit/test_chirp_common.py
+++ b/tests/unit/test_chirp_common.py
@@ -72,11 +72,9 @@ class TestUtilityFunctions(base.BaseTest):
self.assertTrue(chirp_common.is_version_newer('daily-20180101'))
def test_from_Hz(self):
- # FIXME: These are wrong! Adding them here purely to test the
- # python3 conversion, but they should be fixed.
- self.assertEqual(140, chirp_common.from_GHz(14000000001))
- self.assertEqual(140, chirp_common.from_MHz(14000001))
- self.assertEqual(140, chirp_common.from_kHz(14001))
+ self.assertEqual(140, chirp_common.from_GHz(140000000001))
+ self.assertEqual(140, chirp_common.from_MHz(140000001))
+ self.assertEqual(140, chirp_common.from_kHz(140001))
def test_mem_to_from_csv(self):
mem1 = chirp_common.Memory()
@@ -310,6 +308,15 @@ class TestUtilityFunctions(base.BaseTest):
for s in invalid:
self.assertRaises(ValueError, chirp_common.parse_power, s)
+ def test_airband(self):
+ self.assertTrue(chirp_common.is_airband(108000000))
+ self.assertTrue(chirp_common.is_airband(108000000 + 25000))
+ self.assertTrue(chirp_common.is_airband(136000000 - 25000))
+ self.assertTrue(chirp_common.is_airband(136000000))
+
+ self.assertFalse(chirp_common.is_airband(108000000 - 1))
+ self.assertFalse(chirp_common.is_airband(137000000 + 1))
+
class TestSplitTone(base.BaseTest):
def _test_split_tone_decode(self, tx, rx, **vals):
@@ -552,6 +559,74 @@ class TestStepFunctions(base.BaseTest):
self.assertEqual(146520000,
chirp_common.fix_rounded_step(146520000))
+ def test_fix_rounded_step_833(self):
+ # 118.008 should be aligned to 8.33kHz step
+ self.assertEqual(
+ int(118000000 + (25000 / 3)),
+ chirp_common.fix_rounded_step(chirp_common.to_MHz(118.008)))
+
+ # 108.0 MHz should be left unchanged as it is 25kHz-aligned
+ self.assertFalse(chirp_common.is_8_33(
+ chirp_common.to_MHz(108)))
+ self.assertEqual(chirp_common.to_MHz(108),
+ chirp_common.fix_rounded_step(
+ chirp_common.to_MHz(108)))
+
+ # 108.025 MHz should be left unchanged
+ self.assertFalse(chirp_common.is_8_33(
+ chirp_common.to_MHz(108.025)))
+ self.assertEqual(chirp_common.to_MHz(108.025),
+ chirp_common.fix_rounded_step(
+ chirp_common.to_MHz(108.025)))
+
+ # Even though 146.008333 is a valid 8.33kHz step, we should
+ # not align it as such since it is not in airband
+ self.assertTrue(chirp_common.is_8_33(
+ chirp_common.to_MHz(146.008333)))
+ self.assertRaisesRegex(errors.InvalidDataError,
+ 'Unable to correct.*',
+ chirp_common.fix_rounded_step,
+ chirp_common.to_MHz(146.008333))
+
+ # Using a channel name should be aligned to the actual frequency
+ self.assertEqual(
+ int(132050000),
+ chirp_common.fix_rounded_step(chirp_common.to_MHz(132.055)))
+ self.assertEqual(
+ int(132050000) + (25000 // 3),
+ chirp_common.fix_rounded_step(chirp_common.to_MHz(132.060)))
+ self.assertEqual(
+ int(132050000) + (25000 // 3) * 2,
+ chirp_common.fix_rounded_step(chirp_common.to_MHz(132.065)))
+ self.assertEqual(
+ int(132075000),
+ chirp_common.fix_rounded_step(chirp_common.to_MHz(132.080)))
+
+ # This is not valid
+ self.assertRaisesRegex(errors.InvalidDataError,
+ 'Aircraft frequencies must be aligned.*',
+ chirp_common.fix_rounded_step,
+ chirp_common.to_MHz(132.070))
+
+ def test_fix_rounded_step_833_examples(self):
+ # https://ukradiotransmissions.wordpress.com/2019/02/06/new-8-33khz-airband-channel-spacing-frequencies-a-conversion-chart-and-explanation/
+ cases = [
+ (132005000, 132000000),
+ (132010000, 132008300),
+ (132015000, 132016600),
+ (132030000, 132025000),
+ (132035000, 132033300),
+ (132040000, 132041600),
+ (132055000, 132050000),
+ (132060000, 132058300),
+ (132065000, 132066600),
+ (132080000, 132075000),
+ (132085000, 132083300),
+ (132090000, 132091600),
+ ]
+ for channel, freq in cases:
+ pass
+
class TestImageMetadata(base.BaseTest):
def test_make_metadata(self):