From 5087eb07d0f326e26e86101397cfc67cb3d39f95 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 31 May 2012 23:13:02 -0700 Subject: [PATCH] clean up slogan.py and add test --- modules/slogan.py | 5 ++--- modules/test/test_slogan.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 modules/test/test_slogan.py diff --git a/modules/slogan.py b/modules/slogan.py index 4c07e44..d09c10e 100644 --- a/modules/slogan.py +++ b/modules/slogan.py @@ -29,10 +29,9 @@ def slogan(phenny, input): slogan = remove_tags.sub('', slogan) if not slogan: - phenny.say("Looks like an issue with sloganizer.net") - return + phenny.say("Looks like an issue with sloganizer.net") + return phenny.say(slogan) - slogan.commands = ['slogan'] slogan.example = '.slogan Granola' diff --git a/modules/test/test_slogan.py b/modules/test/test_slogan.py new file mode 100644 index 0000000..5ab5f1c --- /dev/null +++ b/modules/test/test_slogan.py @@ -0,0 +1,29 @@ +""" +test_slogan.py - tests for the slogan 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.slogan import sloganize, slogan + +class TestSlogan(unittest.TestCase): + def setUp(self): + self.phenny = MagicMock() + + def test_sloganize(self): + out = sloganize('slogan') + + assert len(out) > 0 + + def test_slogan(self): + input = Mock(group=lambda x: 'slogan') + slogan(self.phenny, input) + out = self.phenny.say.call_args[0][0] + + self.assertNotEqual(out, "Looks like an issue with sloganizer.net")