add tests for fcc callsign lookup module

master
mutantmonkey 2012-05-31 23:04:19 -07:00
parent 59bd004538
commit abc29de35c
1 changed files with 37 additions and 0 deletions

37
modules/test/test_fcc.py Normal file
View File

@ -0,0 +1,37 @@
"""
test_fcc.py - tests for the fcc callsign lookup module
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
"""
# 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))