mirror of
https://github.com/craigerl/aprsd.git
synced 2026-06-07 08:34:40 -04:00
Removed references to old custom config
Also updated unittests to pass.
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from aprsd import conf # noqa: F401
|
||||
from aprsd.plugins import fortune as fortune_plugin
|
||||
|
||||
from .. import fake, test_plugin
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestFortunePlugin(test_plugin.TestPlugin):
|
||||
@mock.patch("shutil.which")
|
||||
def test_fortune_fail(self, mock_which):
|
||||
mock_which.return_value = None
|
||||
fortune = fortune_plugin.FortunePlugin(self.config)
|
||||
fortune = fortune_plugin.FortunePlugin()
|
||||
expected = "FortunePlugin isn't enabled"
|
||||
packet = fake.fake_packet(message="fortune")
|
||||
actual = fortune.filter(packet)
|
||||
@@ -20,7 +26,8 @@ class TestFortunePlugin(test_plugin.TestPlugin):
|
||||
def test_fortune_success(self, mock_which, mock_output):
|
||||
mock_which.return_value = "/usr/bin/games/fortune"
|
||||
mock_output.return_value = "Funny fortune"
|
||||
fortune = fortune_plugin.FortunePlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
fortune = fortune_plugin.FortunePlugin()
|
||||
|
||||
expected = "Funny fortune"
|
||||
packet = fake.fake_packet(message="fortune")
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from aprsd import conf # noqa: F401
|
||||
from aprsd.plugins import location as location_plugin
|
||||
|
||||
from .. import fake, test_plugin
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestLocationPlugin(test_plugin.TestPlugin):
|
||||
|
||||
@mock.patch("aprsd.config.Config.check_option")
|
||||
def test_location_not_enabled_missing_aprs_fi_key(self, mock_check):
|
||||
def test_location_not_enabled_missing_aprs_fi_key(self):
|
||||
# When the aprs.fi api key isn't set, then
|
||||
# the LocationPlugin will be disabled.
|
||||
mock_check.side_effect = Exception
|
||||
fortune = location_plugin.LocationPlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
CONF.aprs_fi.apiKey = None
|
||||
fortune = location_plugin.LocationPlugin()
|
||||
expected = "LocationPlugin isn't enabled"
|
||||
packet = fake.fake_packet(message="location")
|
||||
actual = fortune.filter(packet)
|
||||
@@ -23,7 +29,8 @@ class TestLocationPlugin(test_plugin.TestPlugin):
|
||||
# When the aprs.fi api key isn't set, then
|
||||
# the LocationPlugin will be disabled.
|
||||
mock_check.side_effect = Exception
|
||||
fortune = location_plugin.LocationPlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
fortune = location_plugin.LocationPlugin()
|
||||
expected = "Failed to fetch aprs.fi location"
|
||||
packet = fake.fake_packet(message="location")
|
||||
actual = fortune.filter(packet)
|
||||
@@ -34,7 +41,8 @@ class TestLocationPlugin(test_plugin.TestPlugin):
|
||||
# When the aprs.fi api key isn't set, then
|
||||
# the LocationPlugin will be disabled.
|
||||
mock_check.return_value = {"entries": []}
|
||||
fortune = location_plugin.LocationPlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
fortune = location_plugin.LocationPlugin()
|
||||
expected = "Failed to fetch aprs.fi location"
|
||||
packet = fake.fake_packet(message="location")
|
||||
actual = fortune.filter(packet)
|
||||
@@ -57,7 +65,8 @@ class TestLocationPlugin(test_plugin.TestPlugin):
|
||||
}
|
||||
mock_weather.side_effect = Exception
|
||||
mock_time.return_value = 10
|
||||
fortune = location_plugin.LocationPlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
fortune = location_plugin.LocationPlugin()
|
||||
expected = "KFAKE: Unknown Location 0' 10,11 0.0h ago"
|
||||
packet = fake.fake_packet(message="location")
|
||||
actual = fortune.filter(packet)
|
||||
@@ -82,7 +91,8 @@ class TestLocationPlugin(test_plugin.TestPlugin):
|
||||
wx_data = {"location": {"areaDescription": expected_town}}
|
||||
mock_weather.return_value = wx_data
|
||||
mock_time.return_value = 10
|
||||
fortune = location_plugin.LocationPlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
fortune = location_plugin.LocationPlugin()
|
||||
expected = f"KFAKE: {expected_town} 0' 10,11 0.0h ago"
|
||||
packet = fake.fake_packet(message="location")
|
||||
actual = fortune.filter(packet)
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
from unittest import mock
|
||||
|
||||
from aprsd import client
|
||||
from aprsd import config as aprsd_config
|
||||
from aprsd import packets
|
||||
from oslo_config import cfg
|
||||
|
||||
from aprsd import client, packets
|
||||
from aprsd import conf # noqa: F401
|
||||
from aprsd.plugins import notify as notify_plugin
|
||||
|
||||
from .. import fake, test_plugin
|
||||
|
||||
|
||||
DEFAULT_WATCHLIST_CALLSIGNS = [fake.FAKE_FROM_CALLSIGN]
|
||||
CONF = cfg.CONF
|
||||
DEFAULT_WATCHLIST_CALLSIGNS = fake.FAKE_FROM_CALLSIGN
|
||||
|
||||
|
||||
class TestWatchListPlugin(test_plugin.TestPlugin):
|
||||
@@ -16,7 +18,7 @@ class TestWatchListPlugin(test_plugin.TestPlugin):
|
||||
self.fromcall = fake.FAKE_FROM_CALLSIGN
|
||||
self.ack = 1
|
||||
|
||||
def _config(
|
||||
def config_and_init(
|
||||
self,
|
||||
watchlist_enabled=True,
|
||||
watchlist_alert_callsign=None,
|
||||
@@ -24,39 +26,33 @@ class TestWatchListPlugin(test_plugin.TestPlugin):
|
||||
watchlist_packet_keep_count=None,
|
||||
watchlist_callsigns=DEFAULT_WATCHLIST_CALLSIGNS,
|
||||
):
|
||||
_config = aprsd_config.Config(aprsd_config.DEFAULT_CONFIG_DICT)
|
||||
default_wl = aprsd_config.DEFAULT_CONFIG_DICT["aprsd"]["watch_list"]
|
||||
|
||||
_config["ham"]["callsign"] = self.fromcall
|
||||
_config["aprsd"]["callsign"] = self.fromcall
|
||||
_config["aprs"]["login"] = self.fromcall
|
||||
_config["services"]["aprs.fi"]["apiKey"] = "something"
|
||||
CONF.callsign = self.fromcall
|
||||
CONF.aprs_network.login = self.fromcall
|
||||
CONF.aprs_fi.apiKey = "something"
|
||||
|
||||
# Set the watchlist specific config options
|
||||
CONF.watch_list.enabled = watchlist_enabled
|
||||
|
||||
_config["aprsd"]["watch_list"]["enabled"] = watchlist_enabled
|
||||
if not watchlist_alert_callsign:
|
||||
watchlist_alert_callsign = fake.FAKE_TO_CALLSIGN
|
||||
_config["aprsd"]["watch_list"]["alert_callsign"] = watchlist_alert_callsign
|
||||
CONF.watch_list.alert_callsign = watchlist_alert_callsign
|
||||
|
||||
if not watchlist_alert_time_seconds:
|
||||
watchlist_alert_time_seconds = default_wl["alert_time_seconds"]
|
||||
_config["aprsd"]["watch_list"]["alert_time_seconds"] = watchlist_alert_time_seconds
|
||||
watchlist_alert_time_seconds = CONF.watch_list.alert_time_seconds
|
||||
CONF.watch_list.alert_time_seconds = watchlist_alert_time_seconds
|
||||
|
||||
if not watchlist_packet_keep_count:
|
||||
watchlist_packet_keep_count = default_wl["packet_keep_count"]
|
||||
_config["aprsd"]["watch_list"]["packet_keep_count"] = watchlist_packet_keep_count
|
||||
watchlist_packet_keep_count = CONF.watch_list.packet_keep_count
|
||||
CONF.watch_list.packet_keep_count = watchlist_packet_keep_count
|
||||
|
||||
_config["aprsd"]["watch_list"]["callsigns"] = watchlist_callsigns
|
||||
return _config
|
||||
CONF.watch_list.callsigns = watchlist_callsigns
|
||||
|
||||
|
||||
class TestAPRSDWatchListPluginBase(TestWatchListPlugin):
|
||||
|
||||
def test_watchlist_not_enabled(self):
|
||||
config = self._config(watchlist_enabled=False)
|
||||
self.config_and_init(config=config)
|
||||
plugin = fake.FakeWatchListPlugin(self.config)
|
||||
self.config_and_init(watchlist_enabled=False)
|
||||
plugin = fake.FakeWatchListPlugin()
|
||||
|
||||
packet = fake.fake_packet(
|
||||
message="version",
|
||||
@@ -69,9 +65,8 @@ class TestAPRSDWatchListPluginBase(TestWatchListPlugin):
|
||||
@mock.patch("aprsd.client.ClientFactory", autospec=True)
|
||||
def test_watchlist_not_in_watchlist(self, mock_factory):
|
||||
client.factory = mock_factory
|
||||
config = self._config()
|
||||
self.config_and_init(config=config)
|
||||
plugin = fake.FakeWatchListPlugin(self.config)
|
||||
self.config_and_init()
|
||||
plugin = fake.FakeWatchListPlugin()
|
||||
|
||||
packet = fake.fake_packet(
|
||||
fromcall="FAKE",
|
||||
@@ -86,9 +81,8 @@ class TestAPRSDWatchListPluginBase(TestWatchListPlugin):
|
||||
class TestNotifySeenPlugin(TestWatchListPlugin):
|
||||
|
||||
def test_disabled(self):
|
||||
config = self._config(watchlist_enabled=False)
|
||||
self.config_and_init(config=config)
|
||||
plugin = notify_plugin.NotifySeenPlugin(self.config)
|
||||
self.config_and_init(watchlist_enabled=False)
|
||||
plugin = notify_plugin.NotifySeenPlugin()
|
||||
|
||||
packet = fake.fake_packet(
|
||||
message="version",
|
||||
@@ -101,9 +95,8 @@ class TestNotifySeenPlugin(TestWatchListPlugin):
|
||||
@mock.patch("aprsd.client.ClientFactory", autospec=True)
|
||||
def test_callsign_not_in_watchlist(self, mock_factory):
|
||||
client.factory = mock_factory
|
||||
config = self._config(watchlist_enabled=False)
|
||||
self.config_and_init(config=config)
|
||||
plugin = notify_plugin.NotifySeenPlugin(self.config)
|
||||
self.config_and_init(watchlist_enabled=False)
|
||||
plugin = notify_plugin.NotifySeenPlugin()
|
||||
|
||||
packet = fake.fake_packet(
|
||||
message="version",
|
||||
@@ -118,12 +111,11 @@ class TestNotifySeenPlugin(TestWatchListPlugin):
|
||||
def test_callsign_in_watchlist_not_old(self, mock_is_old, mock_factory):
|
||||
client.factory = mock_factory
|
||||
mock_is_old.return_value = False
|
||||
config = self._config(
|
||||
self.config_and_init(
|
||||
watchlist_enabled=True,
|
||||
watchlist_callsigns=["WB4BOR"],
|
||||
)
|
||||
self.config_and_init(config=config)
|
||||
plugin = notify_plugin.NotifySeenPlugin(self.config)
|
||||
plugin = notify_plugin.NotifySeenPlugin()
|
||||
|
||||
packet = fake.fake_packet(
|
||||
fromcall="WB4BOR",
|
||||
@@ -139,13 +131,12 @@ class TestNotifySeenPlugin(TestWatchListPlugin):
|
||||
def test_callsign_in_watchlist_old_same_alert_callsign(self, mock_is_old, mock_factory):
|
||||
client.factory = mock_factory
|
||||
mock_is_old.return_value = True
|
||||
config = self._config(
|
||||
self.config_and_init(
|
||||
watchlist_enabled=True,
|
||||
watchlist_alert_callsign="WB4BOR",
|
||||
watchlist_callsigns=["WB4BOR"],
|
||||
)
|
||||
self.config_and_init(config=config)
|
||||
plugin = notify_plugin.NotifySeenPlugin(self.config)
|
||||
plugin = notify_plugin.NotifySeenPlugin()
|
||||
|
||||
packet = fake.fake_packet(
|
||||
fromcall="WB4BOR",
|
||||
@@ -163,13 +154,12 @@ class TestNotifySeenPlugin(TestWatchListPlugin):
|
||||
mock_is_old.return_value = True
|
||||
notify_callsign = fake.FAKE_TO_CALLSIGN
|
||||
fromcall = "WB4BOR"
|
||||
config = self._config(
|
||||
self.config_and_init(
|
||||
watchlist_enabled=True,
|
||||
watchlist_alert_callsign=notify_callsign,
|
||||
watchlist_callsigns=["WB4BOR"],
|
||||
)
|
||||
self.config_and_init(config=config)
|
||||
plugin = notify_plugin.NotifySeenPlugin(self.config)
|
||||
plugin = notify_plugin.NotifySeenPlugin()
|
||||
|
||||
packet = fake.fake_packet(
|
||||
fromcall=fromcall,
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from aprsd import conf # noqa: F401
|
||||
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")
|
||||
def test_ping(self, mock_time):
|
||||
@@ -14,7 +20,8 @@ class TestPingPlugin(test_plugin.TestPlugin):
|
||||
s = fake_time.tm_sec = 55
|
||||
mock_time.return_value = fake_time
|
||||
|
||||
ping = ping_plugin.PingPlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
ping = ping_plugin.PingPlugin()
|
||||
|
||||
packet = fake.fake_packet(
|
||||
message="location",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from aprsd import packets
|
||||
from aprsd.packets import tracker
|
||||
from aprsd.plugins import query as query_plugin
|
||||
@@ -7,11 +9,18 @@ from aprsd.plugins import query as query_plugin
|
||||
from .. import fake, test_plugin
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestQueryPlugin(test_plugin.TestPlugin):
|
||||
@mock.patch("aprsd.packets.tracker.PacketTrack.flush")
|
||||
def test_query_flush(self, mock_flush):
|
||||
packet = fake.fake_packet(message="!delete")
|
||||
query = query_plugin.QueryPlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
CONF.save_enabled = True
|
||||
CONF.query_plugin.callsign = fake.FAKE_FROM_CALLSIGN
|
||||
query = query_plugin.QueryPlugin()
|
||||
query.enabled = True
|
||||
|
||||
expected = "Deleted ALL pending msgs."
|
||||
actual = query.filter(packet)
|
||||
@@ -20,10 +29,13 @@ class TestQueryPlugin(test_plugin.TestPlugin):
|
||||
|
||||
@mock.patch("aprsd.packets.tracker.PacketTrack.restart_delayed")
|
||||
def test_query_restart_delayed(self, mock_restart):
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
CONF.save_enabled = True
|
||||
CONF.query_plugin.callsign = fake.FAKE_FROM_CALLSIGN
|
||||
track = tracker.PacketTrack()
|
||||
track.data = {}
|
||||
packet = fake.fake_packet(message="!4")
|
||||
query = query_plugin.QueryPlugin(self.config)
|
||||
query = query_plugin.QueryPlugin()
|
||||
|
||||
expected = "No pending msgs to resend"
|
||||
actual = query.filter(packet)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
import pytz
|
||||
|
||||
from aprsd.plugins import time as time_plugin
|
||||
@@ -8,6 +9,9 @@ from aprsd.utils import fuzzy
|
||||
from .. import fake, test_plugin
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestTimePlugins(test_plugin.TestPlugin):
|
||||
|
||||
@mock.patch("aprsd.plugins.time.TimePlugin._get_local_tz")
|
||||
@@ -25,7 +29,8 @@ class TestTimePlugins(test_plugin.TestPlugin):
|
||||
h = int(local_t.strftime("%H"))
|
||||
m = int(local_t.strftime("%M"))
|
||||
fake_time.tm_sec = 13
|
||||
time = time_plugin.TimePlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
time = time_plugin.TimePlugin()
|
||||
|
||||
packet = fake.fake_packet(
|
||||
message="location",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from unittest import mock
|
||||
from oslo_config import cfg
|
||||
|
||||
import aprsd
|
||||
from aprsd.plugins import version as version_plugin
|
||||
@@ -6,11 +6,16 @@ from aprsd.plugins import version as version_plugin
|
||||
from .. import fake, test_plugin
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestVersionPlugin(test_plugin.TestPlugin):
|
||||
@mock.patch("aprsd.plugin.PluginManager.get_plugins")
|
||||
def test_version(self, mock_get_plugins):
|
||||
|
||||
def test_version(self):
|
||||
expected = f"APRSD ver:{aprsd.__version__} uptime:00:00:00"
|
||||
version = version_plugin.VersionPlugin(self.config)
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
version = version_plugin.VersionPlugin()
|
||||
version.enabled = True
|
||||
|
||||
packet = fake.fake_packet(
|
||||
message="No",
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from aprsd import conf # noqa: F401
|
||||
from aprsd.plugins import weather as weather_plugin
|
||||
|
||||
from .. import fake, test_plugin
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestUSWeatherPluginPlugin(test_plugin.TestPlugin):
|
||||
|
||||
@mock.patch("aprsd.config.Config.check_option")
|
||||
def test_not_enabled_missing_aprs_fi_key(self, mock_check):
|
||||
def test_not_enabled_missing_aprs_fi_key(self):
|
||||
# When the aprs.fi api key isn't set, then
|
||||
# the LocationPlugin will be disabled.
|
||||
mock_check.side_effect = Exception
|
||||
wx = weather_plugin.USWeatherPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = None
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USWeatherPlugin()
|
||||
expected = "USWeatherPlugin isn't enabled"
|
||||
packet = fake.fake_packet(message="weather")
|
||||
actual = wx.filter(packet)
|
||||
@@ -23,7 +29,9 @@ class TestUSWeatherPluginPlugin(test_plugin.TestPlugin):
|
||||
# When the aprs.fi api key isn't set, then
|
||||
# the Plugin will be disabled.
|
||||
mock_check.side_effect = Exception
|
||||
wx = weather_plugin.USWeatherPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = "abc123"
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USWeatherPlugin()
|
||||
expected = "Failed to fetch aprs.fi location"
|
||||
packet = fake.fake_packet(message="weather")
|
||||
actual = wx.filter(packet)
|
||||
@@ -34,7 +42,10 @@ class TestUSWeatherPluginPlugin(test_plugin.TestPlugin):
|
||||
# When the aprs.fi api key isn't set, then
|
||||
# the Plugin will be disabled.
|
||||
mock_check.return_value = {"entries": []}
|
||||
wx = weather_plugin.USWeatherPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = "abc123"
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USWeatherPlugin()
|
||||
wx.enabled = True
|
||||
expected = "Failed to fetch aprs.fi location"
|
||||
packet = fake.fake_packet(message="weather")
|
||||
actual = wx.filter(packet)
|
||||
@@ -55,7 +66,10 @@ class TestUSWeatherPluginPlugin(test_plugin.TestPlugin):
|
||||
],
|
||||
}
|
||||
mock_weather.side_effect = Exception
|
||||
wx = weather_plugin.USWeatherPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = "abc123"
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USWeatherPlugin()
|
||||
wx.enabled = True
|
||||
expected = "Unable to get weather"
|
||||
packet = fake.fake_packet(message="weather")
|
||||
actual = wx.filter(packet)
|
||||
@@ -83,7 +97,10 @@ class TestUSWeatherPluginPlugin(test_plugin.TestPlugin):
|
||||
},
|
||||
"time": {"startPeriodName": ["ignored", "sometime"]},
|
||||
}
|
||||
wx = weather_plugin.USWeatherPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = "abc123"
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USWeatherPlugin()
|
||||
wx.enabled = True
|
||||
expected = "400F(10F/11F) test. sometime, another."
|
||||
packet = fake.fake_packet(message="weather")
|
||||
actual = wx.filter(packet)
|
||||
@@ -92,12 +109,11 @@ class TestUSWeatherPluginPlugin(test_plugin.TestPlugin):
|
||||
|
||||
class TestUSMetarPlugin(test_plugin.TestPlugin):
|
||||
|
||||
@mock.patch("aprsd.config.Config.check_option")
|
||||
def test_not_enabled_missing_aprs_fi_key(self, mock_check):
|
||||
def test_not_enabled_missing_aprs_fi_key(self):
|
||||
# When the aprs.fi api key isn't set, then
|
||||
# the LocationPlugin will be disabled.
|
||||
mock_check.side_effect = Exception
|
||||
wx = weather_plugin.USMetarPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = None
|
||||
wx = weather_plugin.USMetarPlugin()
|
||||
expected = "USMetarPlugin isn't enabled"
|
||||
packet = fake.fake_packet(message="metar")
|
||||
actual = wx.filter(packet)
|
||||
@@ -108,7 +124,10 @@ class TestUSMetarPlugin(test_plugin.TestPlugin):
|
||||
# When the aprs.fi api key isn't set, then
|
||||
# the Plugin will be disabled.
|
||||
mock_check.side_effect = Exception
|
||||
wx = weather_plugin.USMetarPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = "abc123"
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USMetarPlugin()
|
||||
wx.enabled = True
|
||||
expected = "Failed to fetch aprs.fi location"
|
||||
packet = fake.fake_packet(message="metar")
|
||||
actual = wx.filter(packet)
|
||||
@@ -119,7 +138,10 @@ class TestUSMetarPlugin(test_plugin.TestPlugin):
|
||||
# When the aprs.fi api key isn't set, then
|
||||
# the Plugin will be disabled.
|
||||
mock_check.return_value = {"entries": []}
|
||||
wx = weather_plugin.USMetarPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = "abc123"
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USMetarPlugin()
|
||||
wx.enabled = True
|
||||
expected = "Failed to fetch aprs.fi location"
|
||||
packet = fake.fake_packet(message="metar")
|
||||
actual = wx.filter(packet)
|
||||
@@ -128,7 +150,10 @@ class TestUSMetarPlugin(test_plugin.TestPlugin):
|
||||
@mock.patch("aprsd.plugin_utils.get_weather_gov_metar")
|
||||
def test_gov_metar_fetch_fails(self, mock_metar):
|
||||
mock_metar.side_effect = Exception
|
||||
wx = weather_plugin.USMetarPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = "abc123"
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USMetarPlugin()
|
||||
wx.enabled = True
|
||||
expected = "Unable to find station METAR"
|
||||
packet = fake.fake_packet(message="metar KPAO")
|
||||
actual = wx.filter(packet)
|
||||
@@ -141,7 +166,10 @@ class TestUSMetarPlugin(test_plugin.TestPlugin):
|
||||
text = '{"properties": {"rawMessage": "BOGUSMETAR"}}'
|
||||
mock_metar.return_value = Response()
|
||||
|
||||
wx = weather_plugin.USMetarPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = "abc123"
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USMetarPlugin()
|
||||
wx.enabled = True
|
||||
expected = "BOGUSMETAR"
|
||||
packet = fake.fake_packet(message="metar KPAO")
|
||||
actual = wx.filter(packet)
|
||||
@@ -169,7 +197,10 @@ class TestUSMetarPlugin(test_plugin.TestPlugin):
|
||||
}
|
||||
mock_metar.return_value = Response()
|
||||
|
||||
wx = weather_plugin.USMetarPlugin(self.config)
|
||||
CONF.aprs_fi.apiKey = "abc123"
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
wx = weather_plugin.USMetarPlugin()
|
||||
wx.enabled = True
|
||||
expected = "BOGUSMETAR"
|
||||
packet = fake.fake_packet(message="metar")
|
||||
actual = wx.filter(packet)
|
||||
|
||||
Reference in New Issue
Block a user