From b87e62dd479bf5409ebde44cf7ae246fea6be21a Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sat, 2 Jun 2012 15:24:36 -0700 Subject: [PATCH] add randomreddit test --- modules/test/test_randomreddit.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 modules/test/test_randomreddit.py diff --git a/modules/test/test_randomreddit.py b/modules/test/test_randomreddit.py new file mode 100644 index 0000000..6337356 --- /dev/null +++ b/modules/test/test_randomreddit.py @@ -0,0 +1,23 @@ +""" +test_randomredit.py - tests for the randomreddit module +author: mutantmonkey +""" + +import re +import unittest +from mock import MagicMock, Mock +from modules.randomreddit import randomreddit + + +class TestRandomreddit(unittest.TestCase): + def setUp(self): + self.phenny = MagicMock() + + def test_randomreddit(self): + input = Mock(group=lambda x: 'vtluug') + randomreddit(self.phenny, input) + + out = self.phenny.reply.call_args[0][0] + m = re.match('^http://.+? \(.*\)$', + out, flags=re.UNICODE) + self.assertTrue(m)