phenny-1/modules/test/test_imdb.py

40 lines
993 B
Python
Raw Normal View History

2012-05-31 04:17:00 -04:00
"""
2012-06-01 01:31:34 -04:00
test_imdb.py - tests for the imdb module
2012-05-31 04:17:00 -04:00
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
"""
import re
import unittest
from mock import MagicMock, Mock
from modules.imdb import imdb_search, imdb
2012-05-31 04:17:00 -04:00
class TestImdb(unittest.TestCase):
def setUp(self):
self.phenny = MagicMock()
2012-06-01 01:31:34 -04:00
def test_imdb_search(self):
2012-05-31 04:17:00 -04:00
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)
2013-08-25 17:32:42 -04:00
out = self.phenny.say.call_args[0][0]
pattern = re.compile(
r'^.* \(.*\): .* http://imdb.com/title/[a-z\d]+$',
flags=re.UNICODE)
self.assertRegex(out, pattern)
def test_imdb_none(self):
input = Mock(group=lambda x: None)
imdb(self.phenny, input)
self.phenny.say.assert_called_once_with(
".imdb what?")