From b272cfd0f93e38e21078f07077436617e38632ea Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Fri, 1 Jun 2012 00:27:21 -0700 Subject: [PATCH] fix rule34 header and add test --- modules/rule34.py | 2 +- modules/test/test_rule34.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 modules/test/test_rule34.py diff --git a/modules/rule34.py b/modules/rule34.py index 94bca2f..690cb5d 100644 --- a/modules/rule34.py +++ b/modules/rule34.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 """ -rule34.py - urban dictionary module +rule34.py - rule 34 module author: mutantmonkey """ diff --git a/modules/test/test_rule34.py b/modules/test/test_rule34.py new file mode 100644 index 0000000..3d28795 --- /dev/null +++ b/modules/test/test_rule34.py @@ -0,0 +1,29 @@ +""" +test_rule34.py - tests for the rule 34 module +author: mutantmonkey +""" + +import re +import unittest +from mock import MagicMock, Mock +from modules.rule34 import rule34 + + +class TestRule34(unittest.TestCase): + def setUp(self): + self.phenny = MagicMock() + + def test_result(self): + input = Mock(group=lambda x: 'python') + rule34(self.phenny, input) + + out = self.phenny.reply.call_args[0][0] + m = re.match('^!!NSFW!! -> http://rule34\.xxx/.* <- !!NSFW!!$', out, + flags=re.UNICODE) + self.assertTrue(m) + def test_none(self): + input = Mock(group=lambda x: '__no_results_for_this__') + rule34(self.phenny, input) + + self.phenny.reply.assert_called_once_with( + "You just broke Rule 34! Better start uploading...")