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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user