2024-04-01 21:46:23 -04:00
|
|
|
from unittest import mock
|
|
|
|
|
2022-12-27 14:30:03 -05:00
|
|
|
from oslo_config import cfg
|
2021-12-07 11:25:14 -05:00
|
|
|
|
|
|
|
import aprsd
|
|
|
|
from aprsd.plugins import version as version_plugin
|
|
|
|
|
|
|
|
from .. import fake, test_plugin
|
|
|
|
|
|
|
|
|
2022-12-27 14:30:03 -05:00
|
|
|
CONF = cfg.CONF
|
|
|
|
|
|
|
|
|
2021-12-07 11:25:14 -05:00
|
|
|
class TestVersionPlugin(test_plugin.TestPlugin):
|
2022-12-27 14:30:03 -05:00
|
|
|
|
2024-04-01 21:46:23 -04:00
|
|
|
@mock.patch("aprsd.stats.app.APRSDStats.uptime")
|
|
|
|
def test_version(self, mock_stats):
|
|
|
|
mock_stats.return_value = "00:00:00"
|
2021-12-07 11:25:14 -05:00
|
|
|
expected = f"APRSD ver:{aprsd.__version__} uptime:00:00:00"
|
2022-12-27 14:30:03 -05:00
|
|
|
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
|
|
|
version = version_plugin.VersionPlugin()
|
|
|
|
version.enabled = True
|
2021-12-07 11:25:14 -05:00
|
|
|
|
|
|
|
packet = fake.fake_packet(
|
|
|
|
message="No",
|
|
|
|
msg_number=1,
|
|
|
|
)
|
|
|
|
|
|
|
|
actual = version.filter(packet)
|
|
|
|
self.assertEqual(None, actual)
|
|
|
|
|
|
|
|
packet = fake.fake_packet(
|
|
|
|
message="version",
|
|
|
|
msg_number=1,
|
|
|
|
)
|
|
|
|
actual = version.filter(packet)
|
|
|
|
self.assertEqual(expected, actual)
|