From 152132b0ed9772d702ad6712ad2f6e7f8caad165 Mon Sep 17 00:00:00 2001 From: Hemna Date: Wed, 10 Nov 2021 11:51:21 -0500 Subject: [PATCH] Fix test failures --- aprsd/plugins/fortune.py | 2 ++ tests/test_plugin.py | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/aprsd/plugins/fortune.py b/aprsd/plugins/fortune.py index 56c5013..f76ad56 100644 --- a/aprsd/plugins/fortune.py +++ b/aprsd/plugins/fortune.py @@ -21,6 +21,8 @@ class FortunePlugin(plugin.APRSDRegexCommandPluginBase): self.fortune_path = shutil.which("fortune") if not self.fortune_path: self.enabled = False + else: + self.enabled = True @trace.trace def process(self, packet): diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 0d15cc4..2575e6b 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -22,6 +22,7 @@ class TestPlugin(unittest.TestCase): self.config = config.DEFAULT_CONFIG_DICT self.config["ham"]["callsign"] = self.fromcall self.config["aprs"]["login"] = fake.FAKE_TO_CALLSIGN + self.config["services"]["aprs.fi"]["apiKey"] = "something" # Inintialize the stats object with the config stats.APRSDStats(self.config) packets.WatchList(config=self.config) @@ -127,9 +128,9 @@ class TestPlugin(unittest.TestCase): class TestFortunePlugin(TestPlugin): @mock.patch("shutil.which") def test_fortune_fail(self, mock_which): - fortune = fortune_plugin.FortunePlugin(self.config) 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") actual = fortune.filter(packet) self.assertEqual(expected, actual) @@ -137,10 +138,9 @@ class TestFortunePlugin(TestPlugin): @mock.patch("subprocess.check_output") @mock.patch("shutil.which") def test_fortune_success(self, mock_which, mock_output): - fortune = fortune_plugin.FortunePlugin(self.config) - mock_which.return_value = "/usr/bin/games" - + mock_which.return_value = "/usr/bin/games/fortune" mock_output.return_value = "Funny fortune" + fortune = fortune_plugin.FortunePlugin(self.config) expected = "Funny fortune" packet = fake.fake_packet(message="fortune")