From abc29de35c1f51a34699b0e082ab9016b09b9daa Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 31 May 2012 23:04:19 -0700 Subject: [PATCH] add tests for fcc callsign lookup module --- modules/test/test_fcc.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 modules/test/test_fcc.py diff --git a/modules/test/test_fcc.py b/modules/test/test_fcc.py new file mode 100644 index 0000000..e669257 --- /dev/null +++ b/modules/test/test_fcc.py @@ -0,0 +1,37 @@ +""" +test_fcc.py - tests for the fcc callsign lookup module +author: mutantmonkey +""" + +# add current working directory to path +import sys +sys.path.append('.') + +import unittest +from mock import MagicMock, Mock +from modules.fcc import fcc + +class TestFcc(unittest.TestCase): + def setUp(self): + self.phenny = MagicMock() + + def test_result(self): + callsign = 'KK4EWT' + ham = 'JAMES B WILLIAMS' + key = 3326562 + + input = Mock(group=lambda x: 'KK4EWT') + fcc(self.phenny, input) + + self.phenny.say.assert_called_once_with('{0} - {1} - '\ + 'http://wireless2.fcc.gov/UlsApp/UlsSearch/license.jsp?licKey={2}' + .format(callsign, ham, key)) + + def test_none(self): + callsign = 'XFOOBAR' + + input = Mock(group=lambda x: callsign) + fcc(self.phenny, input) + + self.phenny.reply.assert_called_once_with('No results found for '\ + '{0}'.format(callsign))