1
0
mirror of https://github.com/craigerl/aprsd.git synced 2026-06-20 06:38:42 -04:00

Added unit tests for log

This commit is contained in:
2026-01-06 18:57:54 -05:00
parent 8a82a62dc9
commit 26242f7d43
6 changed files with 55 additions and 15 deletions
+19 -1
View File
@@ -30,7 +30,25 @@ def fake_packet(
if response:
packet_dict['response'] = response
return core.factory(packet_dict)
packet = core.factory(packet_dict)
# Call prepare to build the raw data
packet.prepare()
return packet
def fake_gps_packet():
"""Create a properly prepared GPSPacket for testing."""
packet = core.GPSPacket(
from_call=FAKE_FROM_CALLSIGN,
to_call=FAKE_TO_CALLSIGN,
latitude=37.7749,
longitude=-122.4194,
symbol='>',
comment='Test GPS comment',
)
# Call prepare to build the raw data
packet.prepare()
return packet
def fake_ack_packet():
+2 -1
View File
@@ -261,10 +261,11 @@ class TestAPRSDFilterThread(unittest.TestCase):
def test_print_packet(self):
"""Test print_packet() method."""
packet = fake.fake_packet()
self.filter_thread.packet_count = 5 # Set a packet count
with mock.patch('aprsd.threads.rx.packet_log') as mock_log:
self.filter_thread.print_packet(packet)
mock_log.log.assert_called_with(packet)
mock_log.log.assert_called_with(packet, packet_count=5)
def test_loop_with_packet(self):
"""Test loop() with packet in queue."""