From f83154b6e9db514e4fd60331d52ed973b1dc1bf6 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Fri, 28 Aug 2026 14:13:05 -0400 Subject: [PATCH] fix: remove no-op self-assignment 'fromcall = fromcall' in USMetarPlugin (#272) In the else-branch of USMetarPlugin.process(), 'fromcall = fromcall' is a self-assignment that does nothing. It was likely a leftover from an edit that intended to reassign fromcall but forgot to write the RHS. Remove the dead line. The variable is still used correctly on the next line (get_aprs_fi call). Closes #253 --- ChangeLog.md | 2 ++ aprsd/plugins/weather.py | 2 -- tests/plugins/test_weather.py | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7aa8569..8b9d5cd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,6 +8,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). ##### Bug Fixes +- Fix USMetarPlugin.process() self-assignment no-op 'fromcall = fromcall' [`44ff252`](https://github.com/craigerl/aprsd/commit/44ff252) + - Add reset() to @singleton decorator; update tests to use ClassName.reset() instead of ClassName.instance = None [`ef19aaa`](https://github.com/craigerl/aprsd/commit/ef19aaa) - Fix PacketTrack.keys/items/values — return list snapshots instead of live dict views outside the lock [`088436e`](https://github.com/craigerl/aprsd/commit/088436e) diff --git a/aprsd/plugins/weather.py b/aprsd/plugins/weather.py index 6da4a9c..1c80cd5 100644 --- a/aprsd/plugins/weather.py +++ b/aprsd/plugins/weather.py @@ -121,8 +121,6 @@ class USMetarPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin): return reply else: # if no second argument, search for calling station - fromcall = fromcall - api_key = CONF.aprs_fi.apiKey try: diff --git a/tests/plugins/test_weather.py b/tests/plugins/test_weather.py index 539482c..c518d30 100644 --- a/tests/plugins/test_weather.py +++ b/tests/plugins/test_weather.py @@ -202,3 +202,26 @@ class TestUSMetarPlugin(test_plugin.TestPlugin): packet = fake.fake_packet(message='metar') actual = wx.filter(packet) self.assertEqual(expected, actual) + + @mock.patch('aprsd.plugins.weather.plugin_utils.get_aprs_fi') + def test_process_no_station_arg_uses_fromcall(self, mock_aprs_fi): + """USMetarPlugin.process() must use packet.from_call when no station arg given. + + Previously the else-branch contained the no-op 'fromcall = fromcall' which + was dead code. This test verifies that fromcall is still passed correctly + to get_aprs_fi after that line was removed. + """ + mock_aprs_fi.side_effect = Exception('aprs.fi down') + + CONF.aprs_fi.apiKey = 'abc123' + CONF.callsign = fake.FAKE_TO_CALLSIGN + wx = weather_plugin.USMetarPlugin() + wx.enabled = True + + # A message with no second word: regex will not match → else-branch + packet = fake.fake_packet(message='metar') + result = wx.filter(packet) + + # Should call get_aprs_fi with the packet's from_call + mock_aprs_fi.assert_called_once_with('abc123', fake.FAKE_FROM_CALLSIGN) + self.assertIn('Failed', result)