From 226b10f967ceb5c21d93ea2039b94429588d563c Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 31 May 2012 23:56:54 -0700 Subject: [PATCH] remove my life is desi, add mylife tests --- modules/mylife.py | 13 --------- modules/test/__init__.py | 0 modules/test/test_mylife.py | 58 +++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 modules/test/__init__.py create mode 100644 modules/test/test_mylife.py diff --git a/modules/mylife.py b/modules/mylife.py index bcb3e58..e37eca0 100644 --- a/modules/mylife.py +++ b/modules/mylife.py @@ -51,19 +51,6 @@ def mlib(phenny, input): phenny.say(quote) mlib.commands = ['mlib'] -def mlid(phenny, input): - """.mlib - My life is Desi.""" - try: - req = web.get("http://www.mylifeisdesi.com/random") - except (HTTPError, IOError): - phenny.say("MLID is busy at the hookah lounge, be back soon.") - return - - doc = lxml.html.fromstring(req) - quote = doc.find_class('oldlink')[0].text_content() - phenny.say(quote) -mlid.commands = ['mlid'] - def mlig(phenny, input): """.mlig - My life is ginger.""" try: diff --git a/modules/test/__init__.py b/modules/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/modules/test/test_mylife.py b/modules/test/test_mylife.py new file mode 100644 index 0000000..a271faa --- /dev/null +++ b/modules/test/test_mylife.py @@ -0,0 +1,58 @@ +""" +test_mylife.py - tests for the mylife module +author: mutantmonkey +""" + +# add current working directory to path +import sys +sys.path.append('.') + +import unittest +from mock import MagicMock, Mock +from modules import mylife + +class TestMylife(unittest.TestCase): + def setUp(self): + self.phenny = MagicMock() + + def test_fml(self): + mylife.fml(self.phenny, None) + out = self.phenny.say.call_args[0][0] + + self.assertNotEqual(out, + "I tried to use .fml, but it was broken. FML") + + def test_mlia(self): + mylife.mlia(self.phenny, None) + out = self.phenny.say.call_args[0][0] + + self.assertNotEqual(out, + "I tried to use .mlia, but it wasn't loading. MLIA") + + def test_mlib(self): + mylife.mlib(self.phenny, None) + out = self.phenny.say.call_args[0][0] + + self.assertNotEqual(out, + "MLIB is out getting a case of Natty. It's chill.") + + def test_mlih(self): + mylife.mlih(self.phenny, None) + out = self.phenny.say.call_args[0][0] + + self.assertNotEqual(out, + "MLIH is giving some dome to some lax bros.") + + def test_mlihp(self): + mylife.mlihp(self.phenny, None) + out = self.phenny.say.call_args[0][0] + + self.assertNotEqual(out, + "This service is not available to Muggles.") + + def test_mlit(self): + mylife.mlit(self.phenny, None) + out = self.phenny.say.call_args[0][0] + + self.assertNotEqual(out, + "Error: Your life is too Twilight. Go outside.")