1
0
mirror of https://github.com/craigerl/aprsd.git synced 2026-06-11 10:28:45 -04:00

Added unit tests for packets.

Also did some code cleanup.
This commit is contained in:
2026-01-05 16:51:54 -05:00
parent f9979fa3da
commit 1da92e52ef
48 changed files with 1791 additions and 445 deletions
+7 -8
View File
@@ -7,12 +7,11 @@ from aprsd.plugins import ping as ping_plugin
from .. import fake, test_plugin
CONF = cfg.CONF
class TestPingPlugin(test_plugin.TestPlugin):
@mock.patch("time.localtime")
@mock.patch('time.localtime')
def test_ping(self, mock_time):
fake_time = mock.MagicMock()
h = fake_time.tm_hour = 16
@@ -24,7 +23,7 @@ class TestPingPlugin(test_plugin.TestPlugin):
ping = ping_plugin.PingPlugin()
packet = fake.fake_packet(
message="location",
message='location',
msg_number=1,
)
@@ -33,16 +32,16 @@ class TestPingPlugin(test_plugin.TestPlugin):
def ping_str(h, m, s):
return (
"Pong! "
'Pong! '
+ str(h).zfill(2)
+ ":"
+ ':'
+ str(m).zfill(2)
+ ":"
+ ':'
+ str(s).zfill(2)
)
packet = fake.fake_packet(
message="Ping",
message='Ping',
msg_number=1,
)
actual = ping.filter(packet)
@@ -50,7 +49,7 @@ class TestPingPlugin(test_plugin.TestPlugin):
self.assertEqual(expected, actual)
packet = fake.fake_packet(
message="ping",
message='ping',
msg_number=1,
)
actual = ping.filter(packet)