mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 12:49:24 +01:00
ChannelLogger: Add tests for non-relayed messages when rewriteRelayed is True.
This commit is contained in:
parent
01dc289cd6
commit
77682cc50b
@ -103,23 +103,33 @@ class ChannelLoggerTestCase(ChannelPluginTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@patch_open
|
@patch_open
|
||||||
def testLogRewriteRelayedEmulatedEcho(self, mock_open):
|
def _testLogRewriteRelayedEmulatedEcho(self, mock_open, relayed):
|
||||||
with conf.supybot.plugins.ChannelLogger.rewriteRelayed.context(True):
|
with conf.supybot.plugins.ChannelLogger.rewriteRelayed.context(True):
|
||||||
log_file = io.StringIO()
|
log_file = io.StringIO()
|
||||||
mock_open.return_value = log_file
|
mock_open.return_value = log_file
|
||||||
|
|
||||||
msg = ircmsgs.privmsg('#foo', '<someone> test message')
|
msg = ircmsgs.privmsg(
|
||||||
|
'#foo', '<someone> test message', prefix='foo!bar@baz'
|
||||||
|
)
|
||||||
|
if relayed:
|
||||||
msg.tag('relayedMsg')
|
msg.tag('relayedMsg')
|
||||||
self.irc.getCallback('ChannelLogger').outFilter(self.irc, msg)
|
self.irc.getCallback('ChannelLogger').outFilter(self.irc, msg)
|
||||||
self.irc.feedMsg(msg)
|
self.irc.feedMsg(msg)
|
||||||
|
|
||||||
self.assertRegex(
|
if relayed:
|
||||||
log_file.getvalue(),
|
content = '<someone> test message\n'
|
||||||
timestamp_re + '<someone> test message\n'
|
else:
|
||||||
)
|
content = '<foo> <someone> test message\n'
|
||||||
|
self.assertRegex(log_file.getvalue(), timestamp_re + content)
|
||||||
|
|
||||||
|
def testLogRewriteRelayedEmulatedEcho(self):
|
||||||
|
self._testLogRewriteRelayedEmulatedEcho(relayed=True)
|
||||||
|
|
||||||
|
def testLogRewriteRelayedEmulatedEchoNotRelayed(self):
|
||||||
|
self._testLogRewriteRelayedEmulatedEcho(relayed=False)
|
||||||
|
|
||||||
@patch_open
|
@patch_open
|
||||||
def testLogRewriteRelayedRealEcho(self, mock_open):
|
def _testLogRewriteRelayedRealEcho(self, mock_open, relayed):
|
||||||
with conf.supybot.plugins.ChannelLogger.rewriteRelayed.context(True):
|
with conf.supybot.plugins.ChannelLogger.rewriteRelayed.context(True):
|
||||||
log_file = io.StringIO()
|
log_file = io.StringIO()
|
||||||
mock_open.return_value = log_file
|
mock_open.return_value = log_file
|
||||||
@ -131,19 +141,29 @@ class ChannelLoggerTestCase(ChannelPluginTestCase):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
out_msg = ircmsgs.privmsg('#foo', '<someone> test message')
|
out_msg = ircmsgs.privmsg('#foo', '<someone> test message')
|
||||||
|
if relayed:
|
||||||
out_msg.tag('relayedMsg')
|
out_msg.tag('relayedMsg')
|
||||||
self.irc.getCallback('ChannelLogger').outFilter(self.irc, out_msg)
|
self.irc.getCallback('ChannelLogger').outFilter(self.irc, out_msg)
|
||||||
finally:
|
finally:
|
||||||
self.irc.state.capabilities_ack = original_caps
|
self.irc.state.capabilities_ack = original_caps
|
||||||
|
|
||||||
msg = ircmsgs.privmsg('#foo', '<someone> test message')
|
msg = ircmsgs.privmsg(
|
||||||
|
'#foo', '<someone> test message', prefix='foo!bar@baz'
|
||||||
|
)
|
||||||
msg.server_tags['label'] = out_msg.server_tags['label']
|
msg.server_tags['label'] = out_msg.server_tags['label']
|
||||||
self.irc.feedMsg(msg)
|
self.irc.feedMsg(msg)
|
||||||
|
|
||||||
self.assertRegex(
|
if relayed:
|
||||||
log_file.getvalue(),
|
content = '<someone> test message\n'
|
||||||
timestamp_re + '<someone> test message\n'
|
else:
|
||||||
)
|
content = '<foo> <someone> test message\n'
|
||||||
|
self.assertRegex(log_file.getvalue(), timestamp_re + content)
|
||||||
|
|
||||||
|
def testLogRewriteRelayedRealEcho(self):
|
||||||
|
self._testLogRewriteRelayedRealEcho(relayed=True)
|
||||||
|
|
||||||
|
def testLogRewriteRelayedRealEchoNotRelayed(self):
|
||||||
|
self._testLogRewriteRelayedRealEcho(relayed=False)
|
||||||
|
|
||||||
@patch_open
|
@patch_open
|
||||||
def testLogNotice(self, mock_open):
|
def testLogNotice(self, mock_open):
|
||||||
|
Loading…
Reference in New Issue
Block a user