Add tests and fix import issues for WSJT-X/JS8Call

Co-authored-by: SpudGunMan <12676665+SpudGunMan@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-28 19:08:15 +00:00
parent 0f918ebccd
commit 49c88306a0
2 changed files with 27 additions and 4 deletions
+4 -4
View File
@@ -267,6 +267,10 @@ async def voxMonitor():
# Based on WSJT-X UDP protocol specification
# Reference: https://github.com/ckuhtz/ham/blob/main/mcast/recv_decode.py
import socket
import struct
import json
wsjtx_enabled = False
js8call_enabled = False
wsjtx_udp_port = 2237
@@ -289,8 +293,6 @@ try:
js8call_enabled = js8call_detection_enabled
if wsjtx_enabled:
import socket
import struct
# Parse UDP address
if ':' in wsjtx_udp_server_address:
wsjtx_udp_address, port_str = wsjtx_udp_server_address.split(':')
@@ -298,8 +300,6 @@ try:
watched_callsigns.extend(wsjtx_watched_callsigns.split(',') if wsjtx_watched_callsigns else [])
if js8call_enabled:
import socket
import json
# Parse TCP address for JS8Call
if ':' in js8call_server_address:
js8call_tcp_address, port_str = js8call_server_address.split(':')
+23
View File
@@ -421,6 +421,29 @@ class TestBot(unittest.TestCase):
flood_report = get_flood_openmeteo(lat, lon)
self.assertIsInstance(flood_report, str)
def test_check_callsign_match(self):
# Test the callsign filtering function for WSJT-X/JS8Call
from radio import check_callsign_match
# Test with empty filter (should match all)
self.assertTrue(check_callsign_match("CQ K7MHI CN87", []))
# Test exact match
self.assertTrue(check_callsign_match("CQ K7MHI CN87", ["K7MHI"]))
# Test case insensitive match
self.assertTrue(check_callsign_match("CQ k7mhi CN87", ["K7MHI"]))
self.assertTrue(check_callsign_match("CQ K7MHI CN87", ["k7mhi"]))
# Test no match
self.assertFalse(check_callsign_match("CQ W1AW FN31", ["K7MHI"]))
# Test multiple callsigns
self.assertTrue(check_callsign_match("CQ W1AW FN31", ["K7MHI", "W1AW"]))
self.assertTrue(check_callsign_match("K7MHI DE W1AW", ["K7MHI", "W1AW"]))
print("Callsign filtering tests passed")