I'm trying to complete my unit tests for the errbot plugin I am writing. Can anyone tell me how to mock out a helper method which is used by a botcmd method?
Example:
class ChatBot(BotPlugin):
@classmethod
def mycommandhelper(cls):
return 'This is my awesome commandz'
@botcmd
def mycommand(self, message, args):
return self.mycommandhelper()
How can I mock the mycommandhelper class when executing the my command class? In my case this class is performing some remote operations which should not be executed during unit testing.
A very simple/crude way would be to simply redefine the function that does the remote operations. Example:
If you'd like to have this method mocked throughout all of your tests, simply do it in the
setUpunittest method.