Commit e0f93c7e authored by Nitanshu's avatar Nitanshu Committed by Guillaume Binet (

TestBot: Add multi-line command test support (#1238)

parent a0f35732
......@@ -2,6 +2,7 @@ import importlib
import logging
import sys
import unittest
import textwrap
from os.path import sep, abspath
from queue import Queue
from tempfile import mkdtemp
......@@ -450,8 +451,10 @@ class TestBot(object):
def zap_queues(self):
def assertCommand(self, command, response, timeout=5):
def assertCommand(self, command, response, timeout=5, dedent=False):
"""Assert the given command returns the given response"""
if dedent:
command = '\n'.join(textwrap.dedent(command).splitlines()[1:])
msg =
assert response in msg, f'{response} not in {msg}.'
......@@ -364,3 +364,15 @@ def test_mock_injection(testbot):
mock_dict = {'helper_method': helper_mock}
testbot.inject_mocks('Dummy', mock_dict)
assert 'foo' in testbot.exec_command('!baz')
def test_multiline_command(testbot):
!bar title
first line of body
second line of body
'!bar title\nfirst line of body\nsecond line of body',
......@@ -37,3 +37,8 @@ class DummyTest(BotPlugin):
def baz(self, msg, args):
"""Tests mock injection method"""
return self.helper_method('baz')
def bar(self, msg, args):
"""This runs bar."""
return msg
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment