mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-15 12:51:57 -05:00
Fix test failures
This commit is contained in:
parent
7787dc1be4
commit
152132b0ed
@ -21,6 +21,8 @@ class FortunePlugin(plugin.APRSDRegexCommandPluginBase):
|
|||||||
self.fortune_path = shutil.which("fortune")
|
self.fortune_path = shutil.which("fortune")
|
||||||
if not self.fortune_path:
|
if not self.fortune_path:
|
||||||
self.enabled = False
|
self.enabled = False
|
||||||
|
else:
|
||||||
|
self.enabled = True
|
||||||
|
|
||||||
@trace.trace
|
@trace.trace
|
||||||
def process(self, packet):
|
def process(self, packet):
|
||||||
|
@ -22,6 +22,7 @@ class TestPlugin(unittest.TestCase):
|
|||||||
self.config = config.DEFAULT_CONFIG_DICT
|
self.config = config.DEFAULT_CONFIG_DICT
|
||||||
self.config["ham"]["callsign"] = self.fromcall
|
self.config["ham"]["callsign"] = self.fromcall
|
||||||
self.config["aprs"]["login"] = fake.FAKE_TO_CALLSIGN
|
self.config["aprs"]["login"] = fake.FAKE_TO_CALLSIGN
|
||||||
|
self.config["services"]["aprs.fi"]["apiKey"] = "something"
|
||||||
# Inintialize the stats object with the config
|
# Inintialize the stats object with the config
|
||||||
stats.APRSDStats(self.config)
|
stats.APRSDStats(self.config)
|
||||||
packets.WatchList(config=self.config)
|
packets.WatchList(config=self.config)
|
||||||
@ -127,9 +128,9 @@ class TestPlugin(unittest.TestCase):
|
|||||||
class TestFortunePlugin(TestPlugin):
|
class TestFortunePlugin(TestPlugin):
|
||||||
@mock.patch("shutil.which")
|
@mock.patch("shutil.which")
|
||||||
def test_fortune_fail(self, mock_which):
|
def test_fortune_fail(self, mock_which):
|
||||||
fortune = fortune_plugin.FortunePlugin(self.config)
|
|
||||||
mock_which.return_value = None
|
mock_which.return_value = None
|
||||||
expected = "Fortune command not installed"
|
fortune = fortune_plugin.FortunePlugin(self.config)
|
||||||
|
expected = "FortunePlugin isn't enabled"
|
||||||
packet = fake.fake_packet(message="fortune")
|
packet = fake.fake_packet(message="fortune")
|
||||||
actual = fortune.filter(packet)
|
actual = fortune.filter(packet)
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
@ -137,10 +138,9 @@ class TestFortunePlugin(TestPlugin):
|
|||||||
@mock.patch("subprocess.check_output")
|
@mock.patch("subprocess.check_output")
|
||||||
@mock.patch("shutil.which")
|
@mock.patch("shutil.which")
|
||||||
def test_fortune_success(self, mock_which, mock_output):
|
def test_fortune_success(self, mock_which, mock_output):
|
||||||
fortune = fortune_plugin.FortunePlugin(self.config)
|
mock_which.return_value = "/usr/bin/games/fortune"
|
||||||
mock_which.return_value = "/usr/bin/games"
|
|
||||||
|
|
||||||
mock_output.return_value = "Funny fortune"
|
mock_output.return_value = "Funny fortune"
|
||||||
|
fortune = fortune_plugin.FortunePlugin(self.config)
|
||||||
|
|
||||||
expected = "Funny fortune"
|
expected = "Funny fortune"
|
||||||
packet = fake.fake_packet(message="fortune")
|
packet = fake.fake_packet(message="fortune")
|
||||||
|
Loading…
Reference in New Issue
Block a user