mirror of
https://github.com/craigerl/aprsd.git
synced 2026-06-07 16:44:39 -04:00
Added unit tests for packets.
Also did some code cleanup.
This commit is contained in:
@@ -7,29 +7,28 @@ 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")
|
||||
@mock.patch('shutil.which')
|
||||
def test_fortune_fail(self, mock_which):
|
||||
mock_which.return_value = None
|
||||
fortune = fortune_plugin.FortunePlugin()
|
||||
expected = "FortunePlugin isn't enabled"
|
||||
packet = fake.fake_packet(message="fortune")
|
||||
packet = fake.fake_packet(message='fortune')
|
||||
actual = fortune.filter(packet)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@mock.patch("subprocess.check_output")
|
||||
@mock.patch("shutil.which")
|
||||
@mock.patch('subprocess.check_output')
|
||||
@mock.patch('shutil.which')
|
||||
def test_fortune_success(self, mock_which, mock_output):
|
||||
mock_which.return_value = "/usr/bin/games/fortune"
|
||||
mock_output.return_value = "Funny fortune"
|
||||
mock_which.return_value = '/usr/bin/games/fortune'
|
||||
mock_output.return_value = 'Funny fortune'
|
||||
CONF.callsign = fake.FAKE_TO_CALLSIGN
|
||||
fortune = fortune_plugin.FortunePlugin()
|
||||
|
||||
expected = "Funny fortune"
|
||||
packet = fake.fake_packet(message="fortune")
|
||||
expected = 'Funny fortune'
|
||||
packet = fake.fake_packet(message='fortune')
|
||||
actual = fortune.filter(packet)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
Reference in New Issue
Block a user