-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2441 from Exirel/sopel-wrapper-statusmsg-reply
bot, trigger: use status prefix in SopelWrapper
- Loading branch information
Showing
3 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,32 @@ def mockplugin(tmpdir): | |
# ----------------------------------------------------------------------------- | ||
# sopel.bot.SopelWrapper | ||
|
||
def test_wrapper_default_destination(mockbot, triggerfactory): | ||
wrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG #channel :test message') | ||
|
||
assert wrapper.default_destination == '#channel' | ||
|
||
|
||
def test_wrapper_default_destination_none(mockbot, triggerfactory): | ||
wrapper = triggerfactory.wrapper( | ||
mockbot, ':irc.example.com 301 Sopel :I am away.') | ||
|
||
assert wrapper.default_destination is None | ||
|
||
|
||
def test_wrapper_default_destination_statusmsg(mockbot, triggerfactory): | ||
mockbot._isupport = mockbot.isupport.apply( | ||
STATUSMSG=tuple('+'), | ||
) | ||
|
||
wrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG +#channel :test message') | ||
|
||
assert wrapper._trigger.sender == '#channel' | ||
assert wrapper.default_destination == '+#channel' | ||
|
||
|
||
def test_wrapper_say(mockbot, triggerfactory): | ||
wrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG #channel :test message') | ||
|
@@ -112,6 +138,20 @@ def test_wrapper_say(mockbot, triggerfactory): | |
) | ||
|
||
|
||
def test_wrapper_say_statusmsg(mockbot, triggerfactory): | ||
mockbot._isupport = mockbot.isupport.apply( | ||
STATUSMSG=tuple('+'), | ||
) | ||
|
||
wrapper: bot.SopelWrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG +#channel :test message') | ||
wrapper.say('Hi!') | ||
|
||
assert mockbot.backend.message_sent == rawlist( | ||
'PRIVMSG +#channel :Hi!' | ||
) | ||
|
||
|
||
def test_wrapper_say_override_destination(mockbot, triggerfactory): | ||
wrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG #channel :test message') | ||
|
@@ -132,6 +172,20 @@ def test_wrapper_notice(mockbot, triggerfactory): | |
) | ||
|
||
|
||
def test_wrapper_notice_statusmsg(mockbot, triggerfactory): | ||
mockbot._isupport = mockbot.isupport.apply( | ||
STATUSMSG=tuple('+'), | ||
) | ||
|
||
wrapper: bot.SopelWrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG +#channel :test message') | ||
wrapper.notice('Hi!') | ||
|
||
assert mockbot.backend.message_sent == rawlist( | ||
'NOTICE +#channel :Hi!' | ||
) | ||
|
||
|
||
def test_wrapper_notice_override_destination(mockbot, triggerfactory): | ||
wrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG #channel :test message') | ||
|
@@ -152,6 +206,20 @@ def test_wrapper_action(mockbot, triggerfactory): | |
) | ||
|
||
|
||
def test_wrapper_action_statusmsg(mockbot, triggerfactory): | ||
mockbot._isupport = mockbot.isupport.apply( | ||
STATUSMSG=tuple('+'), | ||
) | ||
|
||
wrapper: bot.SopelWrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG +#channel :test message') | ||
wrapper.action('Hi!') | ||
|
||
assert mockbot.backend.message_sent == rawlist( | ||
'PRIVMSG +#channel :\x01ACTION Hi!\x01' | ||
) | ||
|
||
|
||
def test_wrapper_action_override_destination(mockbot, triggerfactory): | ||
wrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG #channel :test message') | ||
|
@@ -172,6 +240,20 @@ def test_wrapper_reply(mockbot, triggerfactory): | |
) | ||
|
||
|
||
def test_wrapper_reply_statusmsg(mockbot, triggerfactory): | ||
mockbot._isupport = mockbot.isupport.apply( | ||
STATUSMSG=tuple('+'), | ||
) | ||
|
||
wrapper: bot.SopelWrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG +#channel :test message') | ||
wrapper.reply('Hi!') | ||
|
||
assert mockbot.backend.message_sent == rawlist( | ||
'PRIVMSG +#channel :Test: Hi!' | ||
) | ||
|
||
|
||
def test_wrapper_reply_override_destination(mockbot, triggerfactory): | ||
wrapper = triggerfactory.wrapper( | ||
mockbot, ':[email protected] PRIVMSG #channel :test message') | ||
|