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:
+19
-1
@@ -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():
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user