def setUp(self): self.bot = MockBot.create() # fake Bitly.setup for testing: self.plug = Bitly() self.plug.excludes = [] self.plug.api = MockBitly()
class BitlyTest(unittest.TestCase): """ Test suite for hamper.plugins.bitly """ def setUp(self): self.bot = MockBot.create() # fake Bitly.setup for testing: self.plug = Bitly() self.plug.excludes = [] self.plug.api = MockBitly() def test_link_already_short(self): self.plug.message(self.bot, { 'user': '******', 'message': 'http://shorty.com'}) self.assertEquals(None, self.bot.last_reply) def test_link_no_title(self): self.plug.message(self.bot, { 'user': '******', 'message': 'http://spammyspamspam.com/'}) self.assertEquals( "spammy's url: http://bit.ly/5h0rT", self.bot.last_reply) def test_link_with_title(self): self.plug.api.fake_title = "The /r/LearnProgramming Mentoring Community" self.plug.message(self.bot, { 'user': '******', 'message': 'have you seen http://reddit.com/r/lpmc/?'}) self.assertEquals( "someone's url: http://bit.ly/5h0rT - Title: The /r/LearnProgramming Mentoring Community", self.bot.last_reply)