add imdb tests

master
mutantmonkey 2012-05-31 01:17:00 -07:00
parent 6aef5cab6f
commit 1b7ef76f15
1 changed files with 33 additions and 0 deletions

33
modules/test/test_imdb.py Normal file
View File

@ -0,0 +1,33 @@
"""
test_imdb.py - tests for the imdb module 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.imdb import imdb_search, imdb
class TestImdb(unittest.TestCase):
def setUp(self):
self.phenny = MagicMock()
def test_imdb_seach(self):
data = imdb_search('Hackers')
assert 'Plot' in data
assert 'Title' in data
assert 'Year' in data
assert 'imdbID' in data
def test_imdb(self):
input = Mock(group=lambda x: 'Antitrust')
imdb(self.phenny, input)
out = self.phenny.reply.call_args[0][0]
m = re.match('^.* \(.*\): .* http://imdb.com/title/[a-z\d]+$', out, flags=re.UNICODE)
self.assertTrue(m)