irc: make log_raw() method testable, and test it#2723
Open
Conversation
With the call to `self.bot.log_raw()` living in the `AsyncioBackend`'s read handler, there was no way to trigger it from tests. Moving the call inside `AbstractBot.on_message()` (which is called for every incoming line anyway) makes the raw log testable via a `caplog` fixture, so we can prove that the bot is logging IRC traffic. There's one wee oddity with literal `\r\n` appearing in the outgoing line but not in the incoming one. It would be ideal if those were consistent with each other, but I haven't looked into that yet.
In the real bot, `AsyncioBackend` uses asyncio's `readuntil()`, which will include the separator `\r\n` in returned lines. Our `MockIRCServer` doesn't modify the line passed to its `message()` method; if it doesn't have a separator at the end, the bot will receive a message with no separator. But the `log_raw()` test needs to prove that a separator gets logged correctly for incoming messages, so let's make sure it's present.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With the call to
self.bot.log_raw()living in theAsyncioBackend's read handler, there was no way to trigger it from tests. (Well… no way without doing a lot of other work.)Moving the call inside
AbstractBot.on_message()(which is called for every incoming line anyway) makes the raw log testable via acaplogfixture, so we can prove that the bot is logging IRC traffic.The new test case proves a point in #2721, but does not close any actual issues.
Checklist
make qa(runsmake lintandmake test)caplog, but no: All passed locally.Notes
There was one wee oddity with literal
\r\nappearing in the outgoing line but not in the incoming one. I added a fix commit addressing it, in lieu of scope creep (making theMockIRCServerensure a trailing\r\n).