add urban dictionary test

master
mutantmonkey 2012-06-01 00:09:44 -07:00
parent 226b10f967
commit 34f3f8a9c4
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
"""
test_urbandict.py - tests for the urban dictionary module
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
"""
# add current working directory to path
import sys
sys.path.append('.')
import re
import unittest
from mock import MagicMock, Mock
from modules.urbandict import urbandict
class TestUrbandict(unittest.TestCase):
def setUp(self):
self.phenny = MagicMock()
def test_result(self):
word = 'slemp'
input = Mock(group=lambda x: word)
urbandict(self.phenny, input)
out = self.phenny.say.call_args[0][0]
m = re.match('^.* - '\
'http://www\.urbandictionary\.com/define\.php\?term=.*$', out,
flags=re.UNICODE)
self.assertTrue(m)
def test_none(self):
word = '__no_word_here__'
input = Mock(group=lambda x: word)
urbandict(self.phenny, input)
self.phenny.say.assert_called_once_with('No results found for '\
'{0}'.format(word))