test_callbacks: Add PluginRegexpTestCase.testReply to check basic behavior

This commit is contained in:
Valentin Lorentz 2022-07-06 22:05:30 +02:00
parent 6a943b8342
commit 3ecb37de10

View File

@ -975,19 +975,33 @@ class MultilinePrivmsgTestCase(ChannelPluginTestCase):
'-' + batch_name,))) '-' + batch_name,)))
class PluginRegexpTestCase(PluginTestCase): class PluginRegexpTestCase(ChannelPluginTestCase):
plugins = () plugins = ()
class PCAR(callbacks.PluginRegexp): class PCAR(callbacks.PluginRegexp):
regexps = ("test",) regexps = ("test", "test2")
def test(self, irc, msg, args): def test(self, irc, msg, args):
"<foo>" "<foo>"
raise callbacks.ArgumentError raise callbacks.ArgumentError
def testNoEscapingArgumentError(self): def test2(self, irc, msg, args):
"<bar>"
irc.reply("hello")
def setUp(self):
super().setUp()
self.irc.addCallback(self.PCAR(self.irc)) self.irc.addCallback(self.PCAR(self.irc))
def testNoEscapingArgumentError(self):
self.assertResponse('test', 'test <foo>') self.assertResponse('test', 'test <foo>')
def testReply(self):
self.irc.feedMsg(ircmsgs.IrcMsg(
prefix=self.prefix,
command='PRIVMSG',
args=(self.channel, 'foo <bar> baz')))
self.assertResponse(' ', 'hello')
class RichReplyMethodsTestCase(PluginTestCase): class RichReplyMethodsTestCase(PluginTestCase):
plugins = ('Config',) plugins = ('Config',)
class NoCapability(callbacks.Plugin): class NoCapability(callbacks.Plugin):