mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-10-31 18:12:45 +00:00
A codex review of the branch found seven places where earlier refactor commits changed behavior. Each is restored here with a test: - base_service imported flood_scope relatively; the local-service loader also runs that file as local_services.base_service, where the import cannot resolve. Now absolute. - Radio-health fields were initialized after commands and services were built, so a plugin constructor reading is_radio_offline raised. They are now set before any plugin. - Removing the per-command can_execute overrides made 31 commands honor skip_channel_check, which their overrides had dropped. BaseCommand.honors_skip_channel_check (False on exactly those commands) keeps them enforcing their channel list. - CommandManager.get_plugin_metadata, WxCommand.get_weather_for_zipcode and PluginLoader.validate_plugin were public compatibility entry points; they are back. - feed_manager stopped exporting DEFAULT_MAX_FEED_RESPONSE_BYTES and DEFAULT_MAX_PARSED_FEED_ITEMS despite the commit saying it re-exported them; it does now. - wx and gwx logged companion-location lookup failures at WARNING; the shared helper logged at debug. It now takes the level. - The INFO 'MESSAGE ROUTING' / 'DIRECT MESSAGE' lines for pubkey-correlated DMs were removed with the dead path_info computation; they are logged again by a log-only helper.
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
"""The INFO route lines for a pubkey-correlated DM are still logged."""
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
from modules.message_handler import RF_MATCH_EXACT, RF_MATCH_FALLBACK, RF_MATCH_KEY, MessageHandler
|
|
|
|
|
|
def _handler(rf):
|
|
mh = object.__new__(MessageHandler)
|
|
mh.logger = MagicMock()
|
|
mh.find_recent_rf_data = MagicMock(return_value=rf)
|
|
mh.decode_meshcore_packet = MagicMock(return_value={"route_type": 1})
|
|
return mh
|
|
|
|
|
|
def _infos(mh):
|
|
return [c.args[0] for c in mh.logger.info.call_args_list]
|
|
|
|
|
|
def test_routed_dm_logs_message_routing():
|
|
mh = _handler({"raw_hex": "aa", RF_MATCH_KEY: RF_MATCH_EXACT,
|
|
"routing_info": {"path_length": 2, "path_nodes": ["01", "02"], "route_type": "FLOOD"}})
|
|
mh._log_dm_routing_from_rf("ab12")
|
|
assert _infos(mh) == ["🛣️ MESSAGE ROUTING: 01,02 (2 hops via FLOOD)"]
|
|
|
|
|
|
def test_direct_dm_logs_direct_message():
|
|
mh = _handler({"raw_hex": "aa", RF_MATCH_KEY: RF_MATCH_EXACT,
|
|
"routing_info": {"path_length": 0, "route_type": "DIRECT"}})
|
|
mh._log_dm_routing_from_rf("ab12")
|
|
assert _infos(mh) == ["📡 DIRECT MESSAGE: Direct via DIRECT"]
|
|
|
|
|
|
def test_uncorrelated_or_missing_rf_logs_nothing_at_info():
|
|
mh = _handler({"raw_hex": "aa", RF_MATCH_KEY: RF_MATCH_FALLBACK,
|
|
"routing_info": {"path_length": 0, "route_type": "DIRECT"}})
|
|
mh._log_dm_routing_from_rf("ab12")
|
|
assert _infos(mh) == []
|
|
mh = _handler(None)
|
|
mh._log_dm_routing_from_rf("ab12")
|
|
assert _infos(mh) == []
|