From 1b7ef76f1525d81e3b8f788656cc3641a74789e6 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 31 May 2012 01:17:00 -0700 Subject: [PATCH] add imdb tests --- modules/test/test_imdb.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 modules/test/test_imdb.py diff --git a/modules/test/test_imdb.py b/modules/test/test_imdb.py new file mode 100644 index 0000000..d84a0e9 --- /dev/null +++ b/modules/test/test_imdb.py @@ -0,0 +1,33 @@ +""" +test_imdb.py - tests for the imdb module module +author: mutantmonkey +""" + +# 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)