-
Notifications
You must be signed in to change notification settings - Fork 101
Testing plugins
Meet Mangukiya edited this page May 29, 2017
·
3 revisions
errbot provides a pytest fixture that can be used to get a minimal errbot instance to test the errbot functionality.
You push in a message -> you pop a message -> assert the popped message with expected output.
Example:
pytest_plugins = ['errbot.backends.test'] # to load the pytest fixture
def test_function(testbot):
testbot.push_message(...)
assert '...' in testbot.pop_message
# testbot is the fixture name. pytest fixtures are used by using the same name as the name of the fixture, then pytest passes the fixture in place of that argument. ;)
# Plugin
class Plugin(BotPlugin):
@botcmd
def cmd(self, msg, args):
...
# call the helper method appropriately
Plugin.helper(...)
@staticmethod
def helper(...):
# do something that doesn't require the plugin object
...
# PluginTest
import Plugin
def test_plug():
assert Plugin.helper(...) == ...