def test_execute_command_tweet(self): account = self.mocker.mock() account.jid self.mocker.result("[email protected]/Adium123") account.api self.mocker.result("api") send_message = self.mocker.mock() send_message("[email protected]/Adium123", "Tweet sent") commands = self.mocker.mock() commands.update_status("this is an example tweet") self.mocker.result("Tweet sent") commands_class = self.mocker.mock() commands_class("api") self.mocker.result(commands) self.mocker.replay() handler = MessageHandler() handler.send_message = send_message handler.commands_class = commands_class handler.execute_command(account, "tweet this is an example tweet") self.mocker.verify()
def test_execute_command_timeline(self): account = self.mocker.mock() account.jid self.mocker.result("[email protected]/Adium123") account.api self.mocker.result("api") send_message = self.mocker.mock() send_message("[email protected]/Adium123", "@foo: bar") commands = self.mocker.mock() commands.home_timeline() self.mocker.result("@foo: bar") commands_class = self.mocker.mock() commands_class("api") self.mocker.result(commands) self.mocker.replay() handler = MessageHandler() handler.send_message = send_message handler.commands_class = commands_class handler.execute_command(account, "timeline") self.mocker.verify()
def test_execute_command_timeline(self): account = self.mocker.mock() account.jid self.mocker.result("[email protected]/Adium123") account.api self.mocker.result("api") send_message = self.mocker.mock() send_message("[email protected]/Adium123", "@foo: bar", u'<a href="http://twitter.com/foo">@foo</a>: bar') home_timeline = self.mocker.mock() home_timeline() self.mocker.result( ("@foo: bar", u'<a href="http://twitter.com/foo">@foo</a>: bar')) commands = self.mocker.mock() commands.resolve("timeline") self.mocker.result((home_timeline, {})) commands_class = self.mocker.mock() commands_class("api") self.mocker.result(commands) self.mocker.replay() handler = MessageHandler() handler.send_message = send_message handler.commands_class = commands_class handler.execute_command(account, "timeline") self.mocker.verify()
def test_execute_command_not_found(self): account = self.mocker.mock() account.jid self.mocker.result("[email protected]/Adium123") account.api self.mocker.result("api") send_message = self.mocker.mock() send_message("[email protected]/Adium123", "unkown command") commands_class = self.mocker.mock() commands_class("api") self.mocker.replay() handler = MessageHandler() handler.send_message = send_message handler.commands_class = commands_class handler.execute_command(account, "foobar") self.mocker.verify()